


<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Probability distributions - torch.distributions &mdash; PyTorch master documentation</title>
  

  
  
  
  
    <link rel="canonical" href="https://pytorch.org/docs/stable/distributions.html"/>
  

  

  
  
    

  

  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <!-- <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css" type="text/css" />
  <link rel="stylesheet" href="_static/css/jit.css" type="text/css" />
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" type="text/css" />
  <link rel="stylesheet" href="_static/katex-math.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="torch.hub" href="hub.html" />
    <link rel="prev" title="Distributed communication package - torch.distributed" href="distributed.html" /> 

  
  <script src="_static/js/modernizr.min.js"></script>

  <!-- Preload the theme fonts -->

<link rel="preload" href="_static/fonts/FreightSans/freight-sans-book.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/FreightSans/freight-sans-medium.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/IBMPlexMono/IBMPlexMono-Medium.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/FreightSans/freight-sans-bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/FreightSans/freight-sans-medium-italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/IBMPlexMono/IBMPlexMono-SemiBold.woff2" as="font" type="font/woff2" crossorigin="anonymous">

<!-- Preload the katex fonts -->

<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Math-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Main-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Main-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Size1-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Size4-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Size2-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Size3-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Caligraphic-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
</head>

<div class="container-fluid header-holder tutorials-header" id="header-holder">
  <div class="container">
    <div class="header-container">
      <a class="header-logo" href="https://pytorch.org/" aria-label="PyTorch"></a>

      <div class="main-menu">
        <ul>
          <li>
            <a href="https://pytorch.org/get-started">Get Started</a>
          </li>

          <li>
            <div class="ecosystem-dropdown">
              <a id="dropdownMenuButton" data-toggle="ecosystem-dropdown">
                Ecosystem
              </a>
              <div class="ecosystem-dropdown-menu">
                <a class="nav-dropdown-item" href="https://pytorch.org/hub"">
                  <span class=dropdown-title>Models (Beta)</span>
                  <p>Discover, publish, and reuse pre-trained models</p>
                </a>
                <a class="nav-dropdown-item" href="https://pytorch.org/ecosystem">
                  <span class=dropdown-title>Tools & Libraries</span>
                  <p>Explore the ecosystem of tools and libraries</p>
                </a>
              </div>
            </div>
          </li>

          <li>
            <a href="https://pytorch.org/mobile">Mobile</a>
          </li>

          <li>
            <a href="https://pytorch.org/blog/">Blog</a>
          </li>

          <li>
            <a href="https://pytorch.org/tutorials">Tutorials</a>
          </li>

          <li class="active">
            <a href="https://pytorch.org/docs/stable/index.html">Docs</a>
          </li>

          <li>
            <div class="resources-dropdown">
              <a id="resourcesDropdownButton" data-toggle="resources-dropdown">
                Resources
              </a>
              <div class="resources-dropdown-menu">
                <a class="nav-dropdown-item" href="https://pytorch.org/resources"">
                  <span class=dropdown-title>Developer Resources</span>
                  <p>Find resources and get questions answered</p>
                </a>
                <a class="nav-dropdown-item" href="https://pytorch.org/features">
                  <span class=dropdown-title>About</span>
                  <p>Learn about PyTorch’s features and capabilities</p>
                </a>
              </div>
            </div>
          </li>

          <li>
            <a href="https://github.com/pytorch/pytorch">Github</a>
          </li>
        </ul>
      </div>

      <a class="main-menu-open-button" href="#" data-behavior="open-mobile-menu"></a>
    </div>

  </div>
</div>


<body class="pytorch-body">

   

    

    <div class="table-of-contents-link-wrapper">
      <span>Table of Contents</span>
      <a href="#" class="toggle-table-of-contents" data-behavior="toggle-table-of-contents"></a>
    </div>

    <nav data-toggle="wy-nav-shift" class="pytorch-left-menu" id="pytorch-left-menu">
      <div class="pytorch-side-scroll">
        <div class="pytorch-menu pytorch-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          <div class="pytorch-left-menu-search">
            

            
              
              
                <div class="version">
                  master (1.5.0 )
                </div>
              
            

            


  


<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search Docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

            
          </div>

          
<div>
  <a style="color:#F05732" href="https://pytorch.org/docs/stable/distributions.html">
    You are viewing unstable developer preview docs.
    Click here to view docs for latest stable release.
  </a>
</div>

            
            
              
            
            
              <p class="caption"><span class="caption-text">Notes</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="notes/amp_examples.html">Automatic Mixed Precision examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/autograd.html">Autograd mechanics</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/broadcasting.html">Broadcasting semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/cpu_threading_torchscript_inference.html">CPU threading and TorchScript inference</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/cuda.html">CUDA semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/ddp.html">Distributed Data Parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/extending.html">Extending PyTorch</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/faq.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/large_scale_deployments.html">Features for large-scale deployments</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/multiprocessing.html">Multiprocessing best practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/randomness.html">Reproducibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/serialization.html">Serialization semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes/windows.html">Windows FAQ</a></li>
</ul>
<p class="caption"><span class="caption-text">Language Bindings</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/cppdocs/">C++ API</a></li>
<li class="toctree-l1"><a class="reference internal" href="packages.html">Javadoc</a></li>
</ul>
<p class="caption"><span class="caption-text">Python API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="torch.html">torch</a></li>
<li class="toctree-l1"><a class="reference internal" href="nn.html">torch.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="nn.functional.html">torch.nn.functional</a></li>
<li class="toctree-l1"><a class="reference internal" href="tensors.html">torch.Tensor</a></li>
<li class="toctree-l1"><a class="reference internal" href="tensor_attributes.html">Tensor Attributes</a></li>
<li class="toctree-l1"><a class="reference internal" href="tensor_view.html">Tensor Views</a></li>
<li class="toctree-l1"><a class="reference internal" href="autograd.html">torch.autograd</a></li>
<li class="toctree-l1"><a class="reference internal" href="cuda.html">torch.cuda</a></li>
<li class="toctree-l1"><a class="reference internal" href="amp.html">torch.cuda.amp</a></li>
<li class="toctree-l1"><a class="reference internal" href="distributed.html">torch.distributed</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">torch.distributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="hub.html">torch.hub</a></li>
<li class="toctree-l1"><a class="reference internal" href="jit.html">torch.jit</a></li>
<li class="toctree-l1"><a class="reference internal" href="nn.init.html">torch.nn.init</a></li>
<li class="toctree-l1"><a class="reference internal" href="onnx.html">torch.onnx</a></li>
<li class="toctree-l1"><a class="reference internal" href="optim.html">torch.optim</a></li>
<li class="toctree-l1"><a class="reference internal" href="quantization.html">Quantization</a></li>
<li class="toctree-l1"><a class="reference internal" href="rpc/index.html">Distributed RPC Framework</a></li>
<li class="toctree-l1"><a class="reference internal" href="random.html">torch.random</a></li>
<li class="toctree-l1"><a class="reference internal" href="sparse.html">torch.sparse</a></li>
<li class="toctree-l1"><a class="reference internal" href="storage.html">torch.Storage</a></li>
<li class="toctree-l1"><a class="reference internal" href="bottleneck.html">torch.utils.bottleneck</a></li>
<li class="toctree-l1"><a class="reference internal" href="checkpoint.html">torch.utils.checkpoint</a></li>
<li class="toctree-l1"><a class="reference internal" href="cpp_extension.html">torch.utils.cpp_extension</a></li>
<li class="toctree-l1"><a class="reference internal" href="data.html">torch.utils.data</a></li>
<li class="toctree-l1"><a class="reference internal" href="dlpack.html">torch.utils.dlpack</a></li>
<li class="toctree-l1"><a class="reference internal" href="model_zoo.html">torch.utils.model_zoo</a></li>
<li class="toctree-l1"><a class="reference internal" href="tensorboard.html">torch.utils.tensorboard</a></li>
<li class="toctree-l1"><a class="reference internal" href="type_info.html">Type Info</a></li>
<li class="toctree-l1"><a class="reference internal" href="named_tensor.html">Named Tensors</a></li>
<li class="toctree-l1"><a class="reference internal" href="name_inference.html">Named Tensors operator coverage</a></li>
<li class="toctree-l1"><a class="reference internal" href="__config__.html">torch.__config__</a></li>
</ul>
<p class="caption"><span class="caption-text">Libraries</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/audio">torchaudio</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/text">torchtext</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/elastic/">TorchElastic</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/serve">TorchServe</a></li>
<li class="toctree-l1"><a class="reference external" href="http://pytorch.org/xla/">PyTorch on XLA Devices</a></li>
</ul>
<p class="caption"><span class="caption-text">Community</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="community/contribution_guide.html">PyTorch Contribution Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="community/governance.html">PyTorch Governance</a></li>
<li class="toctree-l1"><a class="reference internal" href="community/persons_of_interest.html">PyTorch Governance | Persons of Interest</a></li>
</ul>

            
          

        </div>
      </div>
    </nav>

    <div class="pytorch-container">
      <div class="pytorch-page-level-bar" id="pytorch-page-level-bar">
        <div class="pytorch-breadcrumbs-wrapper">
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="pytorch-breadcrumbs">
    
      <li>
        <a href="index.html">
          
            Docs
          
        </a> &gt;
      </li>

        
      <li>Probability distributions - torch.distributions</li>
    
    
      <li class="pytorch-breadcrumbs-aside">
        
            
            <a href="_sources/distributions.rst.txt" rel="nofollow"><img src="_static/images/view-page-source-icon.svg"></a>
          
        
      </li>
    
  </ul>

  
</div>
        </div>

        <div class="pytorch-shortcuts-wrapper" id="pytorch-shortcuts-wrapper">
          Shortcuts
        </div>
      </div>

      <section data-toggle="wy-nav-shift" id="pytorch-content-wrap" class="pytorch-content-wrap">
        <div class="pytorch-content-left">

        
          
          <div class="rst-content">
          
            <div role="main" class="main-content" itemscope="itemscope" itemtype="http://schema.org/Article">
             <article itemprop="articleBody" id="pytorch-article" class="pytorch-article">
              
  <div class="section" id="module-torch.distributions">
<span id="probability-distributions-torch-distributions"></span><h1>Probability distributions - torch.distributions<a class="headerlink" href="#module-torch.distributions" title="Permalink to this headline">¶</a></h1>
<p>The <code class="docutils literal notranslate"><span class="pre">distributions</span></code> package contains parameterizable probability distributions
and sampling functions. This allows the construction of stochastic computation
graphs and stochastic gradient estimators for optimization. This package
generally follows the design of the <a class="reference external" href="https://arxiv.org/abs/1711.10604">TensorFlow Distributions</a> package.</p>
<p>It is not possible to directly backpropagate through random samples. However,
there are two main methods for creating surrogate functions that can be
backpropagated through. These are the score function estimator/likelihood ratio
estimator/REINFORCE and the pathwise derivative estimator. REINFORCE is commonly
seen as the basis for policy gradient methods in reinforcement learning, and the
pathwise derivative estimator is commonly seen in the reparameterization trick
in variational autoencoders. Whilst the score function only requires the value
of samples <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">f(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.10764em;">f</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span></span>

</span>, the pathwise derivative requires the derivative
<span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>f</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">f&#x27;(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.001892em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathdefault" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.751892em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span></span>

</span>. The next sections discuss these two in a reinforcement learning
example. For more details see
<a class="reference external" href="https://arxiv.org/abs/1506.05254">Gradient Estimation Using Stochastic Computation Graphs</a> .</p>
<div class="section" id="score-function">
<h2>Score function<a class="headerlink" href="#score-function" title="Permalink to this headline">¶</a></h2>
<p>When the probability density function is differentiable with respect to its
parameters, we only need <code class="xref py py-meth docutils literal notranslate"><span class="pre">sample()</span></code> and
<code class="xref py py-meth docutils literal notranslate"><span class="pre">log_prob()</span></code> to implement REINFORCE:</p>
<div class="math">
<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>θ</mi><mo>=</mo><mi>α</mi><mi>r</mi><mfrac><mrow><mi mathvariant="normal">∂</mi><mi>log</mi><mo>⁡</mo><mi>p</mi><mo stretchy="false">(</mo><mi>a</mi><mi mathvariant="normal">∣</mi><msup><mi>π</mi><mi>θ</mi></msup><mo stretchy="false">(</mo><mi>s</mi><mo stretchy="false">)</mo><mo stretchy="false">)</mo></mrow><mrow><mi mathvariant="normal">∂</mi><mi>θ</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">\Delta\theta  = \alpha r \frac{\partial\log p(a|\pi^\theta(s))}{\partial\theta}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.69444em;vertical-align:0em;"></span><span class="mord">Δ</span><span class="mord mathdefault" style="margin-right:0.02778em;">θ</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:2.212108em;vertical-align:-0.686em;"></span><span class="mord mathdefault" style="margin-right:0.0037em;">α</span><span class="mord mathdefault" style="margin-right:0.02778em;">r</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.526108em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord mathdefault" style="margin-right:0.02778em;">θ</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathdefault">p</span><span class="mopen">(</span><span class="mord mathdefault">a</span><span class="mord">∣</span><span class="mord"><span class="mord mathdefault" style="margin-right:0.03588em;">π</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.849108em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathdefault mtight" style="margin-right:0.02778em;">θ</span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathdefault">s</span><span class="mclose">)</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span>

</div><p>where <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.69444em;vertical-align:0em;"></span><span class="mord mathdefault" style="margin-right:0.02778em;">θ</span></span></span></span>

</span> are the parameters, <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.43056em;vertical-align:0em;"></span><span class="mord mathdefault" style="margin-right:0.0037em;">α</span></span></span></span>

</span> is the learning rate,
<span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi></mrow><annotation encoding="application/x-tex">r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.43056em;vertical-align:0em;"></span><span class="mord mathdefault" style="margin-right:0.02778em;">r</span></span></span></span>

</span> is the reward and <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo stretchy="false">(</mo><mi>a</mi><mi mathvariant="normal">∣</mi><msup><mi>π</mi><mi>θ</mi></msup><mo stretchy="false">(</mo><mi>s</mi><mo stretchy="false">)</mo><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">p(a|\pi^\theta(s))</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.099108em;vertical-align:-0.25em;"></span><span class="mord mathdefault">p</span><span class="mopen">(</span><span class="mord mathdefault">a</span><span class="mord">∣</span><span class="mord"><span class="mord mathdefault" style="margin-right:0.03588em;">π</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.849108em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathdefault mtight" style="margin-right:0.02778em;">θ</span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathdefault">s</span><span class="mclose">)</span><span class="mclose">)</span></span></span></span>

</span> is the probability of
taking action <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.43056em;vertical-align:0em;"></span><span class="mord mathdefault">a</span></span></span></span>

</span> in state <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>s</mi></mrow><annotation encoding="application/x-tex">s</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.43056em;vertical-align:0em;"></span><span class="mord mathdefault">s</span></span></span></span>

</span> given policy <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>π</mi><mi>θ</mi></msup></mrow><annotation encoding="application/x-tex">\pi^\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.849108em;vertical-align:0em;"></span><span class="mord"><span class="mord mathdefault" style="margin-right:0.03588em;">π</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.849108em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathdefault mtight" style="margin-right:0.02778em;">θ</span></span></span></span></span></span></span></span></span></span></span>

</span>.</p>
<p>In practice we would sample an action from the output of a network, apply this
action in an environment, and then use <code class="docutils literal notranslate"><span class="pre">log_prob</span></code> to construct an equivalent
loss function. Note that we use a negative because optimizers use gradient
descent, whilst the rule above assumes gradient ascent. With a categorical
policy, the code for implementing REINFORCE would be as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">probs</span> <span class="o">=</span> <span class="n">policy_network</span><span class="p">(</span><span class="n">state</span><span class="p">)</span>
<span class="c1"># Note that this is equivalent to what used to be called multinomial</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">Categorical</span><span class="p">(</span><span class="n">probs</span><span class="p">)</span>
<span class="n">action</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
<span class="n">next_state</span><span class="p">,</span> <span class="n">reward</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">step</span><span class="p">(</span><span class="n">action</span><span class="p">)</span>
<span class="n">loss</span> <span class="o">=</span> <span class="o">-</span><span class="n">m</span><span class="o">.</span><span class="n">log_prob</span><span class="p">(</span><span class="n">action</span><span class="p">)</span> <span class="o">*</span> <span class="n">reward</span>
<span class="n">loss</span><span class="o">.</span><span class="n">backward</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="pathwise-derivative">
<h2>Pathwise derivative<a class="headerlink" href="#pathwise-derivative" title="Permalink to this headline">¶</a></h2>
<p>The other way to implement these stochastic/policy gradients would be to use the
reparameterization trick from the
<code class="xref py py-meth docutils literal notranslate"><span class="pre">rsample()</span></code> method, where the
parameterized random variable can be constructed via a parameterized
deterministic function of a parameter-free random variable. The reparameterized
sample therefore becomes differentiable. The code for implementing the pathwise
derivative would be as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">params</span> <span class="o">=</span> <span class="n">policy_network</span><span class="p">(</span><span class="n">state</span><span class="p">)</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">Normal</span><span class="p">(</span><span class="o">*</span><span class="n">params</span><span class="p">)</span>
<span class="c1"># Any distribution with .has_rsample == True could work based on the application</span>
<span class="n">action</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">rsample</span><span class="p">()</span>
<span class="n">next_state</span><span class="p">,</span> <span class="n">reward</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">step</span><span class="p">(</span><span class="n">action</span><span class="p">)</span>  <span class="c1"># Assuming that reward is differentiable</span>
<span class="n">loss</span> <span class="o">=</span> <span class="o">-</span><span class="n">reward</span>
<span class="n">loss</span><span class="o">.</span><span class="n">backward</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="distribution">
<h2><span class="hidden-section">Distribution</span><a class="headerlink" href="#distribution" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.distribution.Distribution">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.distribution.</code><code class="sig-name descname">Distribution</code><span class="sig-paren">(</span><em class="sig-param">batch_shape=torch.Size([])</em>, <em class="sig-param">event_shape=torch.Size([])</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>Distribution is the abstract base class for probability distributions.</p>
<dl class="method">
<dt id="torch.distributions.distribution.Distribution.arg_constraints">
<em class="property">property </em><code class="sig-name descname">arg_constraints</code><a class="headerlink" href="#torch.distributions.distribution.Distribution.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a dictionary from argument names to
<a class="reference internal" href="#torch.distributions.constraints.Constraint" title="torch.distributions.constraints.Constraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code></a> objects that
should be satisfied by each argument of this distribution. Args that
are not tensors need not appear in this dict.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.batch_shape">
<em class="property">property </em><code class="sig-name descname">batch_shape</code><a class="headerlink" href="#torch.distributions.distribution.Distribution.batch_shape" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the shape over which parameters are batched.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.cdf" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the cumulative density/mass function evaluated at
<cite>value</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>value</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – </p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.entropy" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns entropy of distribution, batched over batch_shape.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Tensor of shape batch_shape.</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.enumerate_support">
<code class="sig-name descname">enumerate_support</code><span class="sig-paren">(</span><em class="sig-param">expand=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.enumerate_support"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns tensor containing all values supported by a discrete
distribution. The result will enumerate over dimension 0, so the shape
of the result will be <cite>(cardinality,) + batch_shape + event_shape</cite>
(where <cite>event_shape = ()</cite> for univariate distributions).</p>
<p>Note that this enumerates over all batched tensors in lock-step
<cite>[[0, 0], [1, 1], …]</cite>. With <cite>expand=False</cite>, enumeration happens
along dim 0, but with the remaining batch dimensions being
singleton dimensions, <cite>[[0], [1], ..</cite>.</p>
<p>To iterate over the full Cartesian product use
<cite>itertools.product(m.enumerate_support())</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expand</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a>) – whether to expand the support over the
batch dims to match the distribution’s <cite>batch_shape</cite>.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Tensor iterating over dimension 0.</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.event_shape">
<em class="property">property </em><code class="sig-name descname">event_shape</code><a class="headerlink" href="#torch.distributions.distribution.Distribution.event_shape" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the shape of a single sample (without batching).</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.expand" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a new distribution instance (or populates an existing instance
provided by a derived class) with batch dimensions expanded to
<cite>batch_shape</cite>. This method calls <a class="reference internal" href="tensors.html#torch.Tensor.expand" title="torch.Tensor.expand"><code class="xref py py-class docutils literal notranslate"><span class="pre">expand</span></code></a> on
the distribution’s parameters. As such, this does not allocate new
memory for the expanded distribution instance. Additionally,
this does not repeat any args checking or parameter broadcasting in
<cite>__init__.py</cite>, when an instance is first created.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_shape</strong> (<em>torch.Size</em>) – the desired expanded size.</p></li>
<li><p><strong>_instance</strong> – new instance provided by subclasses that
need to override <cite>.expand</cite>.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>New distribution instance with batch dimensions expanded to
<cite>batch_size</cite>.</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.icdf" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the inverse cumulative density/mass function evaluated at
<cite>value</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>value</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – </p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.log_prob" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the log of the probability density/mass function evaluated at
<cite>value</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>value</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – </p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.distribution.Distribution.mean" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the mean of the distribution.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.perplexity">
<code class="sig-name descname">perplexity</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.perplexity"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.perplexity" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns perplexity of distribution, batched over batch_shape.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Tensor of shape batch_shape.</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.rsample" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates a sample_shape shaped reparameterized sample or sample_shape
shaped batch of reparameterized samples if the distribution parameters
are batched.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.sample" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates a sample_shape shaped sample or sample_shape shaped batch of
samples if the distribution parameters are batched.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.sample_n">
<code class="sig-name descname">sample_n</code><span class="sig-paren">(</span><em class="sig-param">n</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/distribution.html#Distribution.sample_n"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.distribution.Distribution.sample_n" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates n samples or n batches of samples if the distribution
parameters are batched.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.stddev">
<em class="property">property </em><code class="sig-name descname">stddev</code><a class="headerlink" href="#torch.distributions.distribution.Distribution.stddev" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the standard deviation of the distribution.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.distribution.Distribution.support" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#torch.distributions.constraints.Constraint" title="torch.distributions.constraints.Constraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code></a> object
representing this distribution’s support.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.distribution.Distribution.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.distribution.Distribution.variance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the variance of the distribution.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="exponentialfamily">
<h2><span class="hidden-section">ExponentialFamily</span><a class="headerlink" href="#exponentialfamily" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.exp_family.ExponentialFamily">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.exp_family.</code><code class="sig-name descname">ExponentialFamily</code><span class="sig-paren">(</span><em class="sig-param">batch_shape=torch.Size([])</em>, <em class="sig-param">event_shape=torch.Size([])</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exp_family.html#ExponentialFamily"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exp_family.ExponentialFamily" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>ExponentialFamily is the abstract base class for probability distributions belonging to an
exponential family, whose probability mass/density function has the form is defined below</p>
<div class="math">
<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>F</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">;</mo><mi>θ</mi><mo stretchy="false">)</mo><mo>=</mo><mi>exp</mi><mo>⁡</mo><mo stretchy="false">(</mo><mo stretchy="false">⟨</mo><mi>t</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>θ</mi><mo stretchy="false">⟩</mo><mo>−</mo><mi>F</mi><mo stretchy="false">(</mo><mi>θ</mi><mo stretchy="false">)</mo><mo>+</mo><mi>k</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">p_{F}(x; \theta) = \exp(\langle t(x), \theta\rangle - F(\theta) + k(x))</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathdefault">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.32833099999999993em;"><span style="top:-2.5500000000000003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathdefault mtight" style="margin-right:0.13889em;">F</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mpunct">;</span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathdefault" style="margin-right:0.02778em;">θ</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">exp</span><span class="mopen">(</span><span class="mopen">⟨</span><span class="mord mathdefault">t</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathdefault" style="margin-right:0.02778em;">θ</span><span class="mclose">⟩</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.13889em;">F</span><span class="mopen">(</span><span class="mord mathdefault" style="margin-right:0.02778em;">θ</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.03148em;">k</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span><span class="mclose">)</span></span></span></span></span>

</div><p>where <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.69444em;vertical-align:0em;"></span><span class="mord mathdefault" style="margin-right:0.02778em;">θ</span></span></span></span>

</span> denotes the natural parameters, <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>t</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">t(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault">t</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span></span>

</span> denotes the sufficient statistic,
<span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo stretchy="false">(</mo><mi>θ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">F(\theta)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.13889em;">F</span><span class="mopen">(</span><span class="mord mathdefault" style="margin-right:0.02778em;">θ</span><span class="mclose">)</span></span></span></span>

</span> is the log normalizer function for a given family and <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">k(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.03148em;">k</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span></span>

</span> is the carrier
measure.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This class is an intermediary between the <cite>Distribution</cite> class and distributions which belong
to an exponential family mainly to check the correctness of the <cite>.entropy()</cite> and analytic KL
divergence methods. We use this class to compute the entropy and KL divergence using the AD
framework and Bregman divergences (courtesy of: Frank Nielsen and Richard Nock, Entropies and
Cross-entropies of Exponential Families).</p>
</div>
<dl class="method">
<dt id="torch.distributions.exp_family.ExponentialFamily.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exp_family.html#ExponentialFamily.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exp_family.ExponentialFamily.entropy" title="Permalink to this definition">¶</a></dt>
<dd><p>Method to compute the entropy using Bregman divergence of the log normalizer.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="bernoulli">
<h2><span class="hidden-section">Bernoulli</span><a class="headerlink" href="#bernoulli" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.bernoulli.Bernoulli">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.bernoulli.</code><code class="sig-name descname">Bernoulli</code><span class="sig-paren">(</span><em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/bernoulli.html#Bernoulli"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.exp_family.ExponentialFamily" title="torch.distributions.exp_family.ExponentialFamily"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.exp_family.ExponentialFamily</span></code></a></p>
<p>Creates a Bernoulli distribution parameterized by <a class="reference internal" href="#torch.distributions.bernoulli.Bernoulli.probs" title="torch.distributions.bernoulli.Bernoulli.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a>
or <a class="reference internal" href="#torch.distributions.bernoulli.Bernoulli.logits" title="torch.distributions.bernoulli.Bernoulli.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a> (but not both).</p>
<p>Samples are binary (0 or 1). They take the value <cite>1</cite> with probability <cite>p</cite>
and <cite>0</cite> with probability <cite>1 - p</cite>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Bernoulli</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.3</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># 30% chance 1; 70% chance 0</span>
<span class="go">tensor([ 0.])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>probs</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the probability of sampling <cite>1</cite></p></li>
<li><p><strong>logits</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the log-odds of sampling <cite>1</cite></p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.bernoulli.Bernoulli.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0)}</em><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.bernoulli.Bernoulli.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/bernoulli.html#Bernoulli.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.bernoulli.Bernoulli.enumerate_support">
<code class="sig-name descname">enumerate_support</code><span class="sig-paren">(</span><em class="sig-param">expand=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/bernoulli.html#Bernoulli.enumerate_support"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.bernoulli.Bernoulli.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/bernoulli.html#Bernoulli.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.bernoulli.Bernoulli.has_enumerate_support">
<code class="sig-name descname">has_enumerate_support</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.has_enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.bernoulli.Bernoulli.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/bernoulli.html#Bernoulli.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.bernoulli.Bernoulli.logits">
<code class="sig-name descname">logits</code><a class="reference internal" href="_modules/torch/distributions/bernoulli.html#Bernoulli.logits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.bernoulli.Bernoulli.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.bernoulli.Bernoulli.param_shape">
<em class="property">property </em><code class="sig-name descname">param_shape</code><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.param_shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.bernoulli.Bernoulli.probs">
<code class="sig-name descname">probs</code><a class="reference internal" href="_modules/torch/distributions/bernoulli.html#Bernoulli.probs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.bernoulli.Bernoulli.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/bernoulli.html#Bernoulli.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.bernoulli.Bernoulli.support">
<code class="sig-name descname">support</code><em class="property"> = Boolean()</em><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.bernoulli.Bernoulli.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.bernoulli.Bernoulli.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="beta">
<h2><span class="hidden-section">Beta</span><a class="headerlink" href="#beta" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.beta.Beta">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.beta.</code><code class="sig-name descname">Beta</code><span class="sig-paren">(</span><em class="sig-param">concentration1</em>, <em class="sig-param">concentration0</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/beta.html#Beta"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.beta.Beta" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.exp_family.ExponentialFamily" title="torch.distributions.exp_family.ExponentialFamily"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.exp_family.ExponentialFamily</span></code></a></p>
<p>Beta distribution parameterized by <a class="reference internal" href="#torch.distributions.beta.Beta.concentration1" title="torch.distributions.beta.Beta.concentration1"><code class="xref py py-attr docutils literal notranslate"><span class="pre">concentration1</span></code></a> and <a class="reference internal" href="#torch.distributions.beta.Beta.concentration0" title="torch.distributions.beta.Beta.concentration0"><code class="xref py py-attr docutils literal notranslate"><span class="pre">concentration0</span></code></a>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Beta</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.5</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.5</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># Beta distributed with concentration concentration1 and concentration0</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>concentration1</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – 1st concentration parameter of the distribution
(often referred to as alpha)</p></li>
<li><p><strong>concentration0</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – 2nd concentration parameter of the distribution
(often referred to as beta)</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.beta.Beta.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'concentration0': GreaterThan(lower_bound=0.0), 'concentration1': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.beta.Beta.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.beta.Beta.concentration0">
<em class="property">property </em><code class="sig-name descname">concentration0</code><a class="headerlink" href="#torch.distributions.beta.Beta.concentration0" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.beta.Beta.concentration1">
<em class="property">property </em><code class="sig-name descname">concentration1</code><a class="headerlink" href="#torch.distributions.beta.Beta.concentration1" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.beta.Beta.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/beta.html#Beta.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.beta.Beta.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.beta.Beta.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/beta.html#Beta.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.beta.Beta.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.beta.Beta.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.beta.Beta.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.beta.Beta.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/beta.html#Beta.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.beta.Beta.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.beta.Beta.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.beta.Beta.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.beta.Beta.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=()</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/beta.html#Beta.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.beta.Beta.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.beta.Beta.support">
<code class="sig-name descname">support</code><em class="property"> = Interval(lower_bound=0.0, upper_bound=1.0)</em><a class="headerlink" href="#torch.distributions.beta.Beta.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.beta.Beta.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.beta.Beta.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="binomial">
<h2><span class="hidden-section">Binomial</span><a class="headerlink" href="#binomial" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.binomial.Binomial">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.binomial.</code><code class="sig-name descname">Binomial</code><span class="sig-paren">(</span><em class="sig-param">total_count=1</em>, <em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/binomial.html#Binomial"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.binomial.Binomial" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a Binomial distribution parameterized by <code class="xref py py-attr docutils literal notranslate"><span class="pre">total_count</span></code> and
either <a class="reference internal" href="#torch.distributions.binomial.Binomial.probs" title="torch.distributions.binomial.Binomial.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> or <a class="reference internal" href="#torch.distributions.binomial.Binomial.logits" title="torch.distributions.binomial.Binomial.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a> (but not both). <code class="xref py py-attr docutils literal notranslate"><span class="pre">total_count</span></code> must be
broadcastable with <a class="reference internal" href="#torch.distributions.binomial.Binomial.probs" title="torch.distributions.binomial.Binomial.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a>/<a class="reference internal" href="#torch.distributions.binomial.Binomial.logits" title="torch.distributions.binomial.Binomial.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Binomial</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mi">0</span> <span class="p">,</span> <span class="o">.</span><span class="mi">2</span><span class="p">,</span> <span class="o">.</span><span class="mi">8</span><span class="p">,</span> <span class="mi">1</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
<span class="go">tensor([   0.,   22.,   71.,  100.])</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Binomial</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([[</span><span class="mf">5.</span><span class="p">],</span> <span class="p">[</span><span class="mf">10.</span><span class="p">]]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.8</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
<span class="go">tensor([[ 4.,  5.],</span>
<span class="go">        [ 7.,  6.]])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>total_count</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – number of Bernoulli trials</p></li>
<li><p><strong>probs</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Event probabilities</p></li>
<li><p><strong>logits</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Event log-odds</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.binomial.Binomial.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0), 'total_count': IntegerGreaterThan(lower_bound=0)}</em><a class="headerlink" href="#torch.distributions.binomial.Binomial.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.binomial.Binomial.enumerate_support">
<code class="sig-name descname">enumerate_support</code><span class="sig-paren">(</span><em class="sig-param">expand=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/binomial.html#Binomial.enumerate_support"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.binomial.Binomial.enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.binomial.Binomial.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/binomial.html#Binomial.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.binomial.Binomial.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.binomial.Binomial.has_enumerate_support">
<code class="sig-name descname">has_enumerate_support</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.binomial.Binomial.has_enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.binomial.Binomial.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/binomial.html#Binomial.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.binomial.Binomial.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.binomial.Binomial.logits">
<code class="sig-name descname">logits</code><a class="reference internal" href="_modules/torch/distributions/binomial.html#Binomial.logits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.binomial.Binomial.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.binomial.Binomial.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.binomial.Binomial.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.binomial.Binomial.param_shape">
<em class="property">property </em><code class="sig-name descname">param_shape</code><a class="headerlink" href="#torch.distributions.binomial.Binomial.param_shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.binomial.Binomial.probs">
<code class="sig-name descname">probs</code><a class="reference internal" href="_modules/torch/distributions/binomial.html#Binomial.probs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.binomial.Binomial.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.binomial.Binomial.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/binomial.html#Binomial.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.binomial.Binomial.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.binomial.Binomial.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.binomial.Binomial.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.binomial.Binomial.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.binomial.Binomial.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="categorical">
<h2><span class="hidden-section">Categorical</span><a class="headerlink" href="#categorical" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.categorical.Categorical">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.categorical.</code><code class="sig-name descname">Categorical</code><span class="sig-paren">(</span><em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/categorical.html#Categorical"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.categorical.Categorical" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a categorical distribution parameterized by either <a class="reference internal" href="#torch.distributions.categorical.Categorical.probs" title="torch.distributions.categorical.Categorical.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> or
<a class="reference internal" href="#torch.distributions.categorical.Categorical.logits" title="torch.distributions.categorical.Categorical.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a> (but not both).</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>It is equivalent to the distribution that <a class="reference internal" href="torch.html#torch.multinomial" title="torch.multinomial"><code class="xref py py-func docutils literal notranslate"><span class="pre">torch.multinomial()</span></code></a>
samples from.</p>
</div>
<p>Samples are integers from <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo><mn>0</mn><mo separator="true">,</mo><mo>…</mo><mo separator="true">,</mo><mi>K</mi><mo>−</mo><mn>1</mn><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\{0, \ldots, K-1\}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="minner">…</span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathdefault" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1</span><span class="mclose">}</span></span></span></span>

</span> where <cite>K</cite> is <code class="docutils literal notranslate"><span class="pre">probs.size(-1)</span></code>.</p>
<p>If <a class="reference internal" href="#torch.distributions.categorical.Categorical.probs" title="torch.distributions.categorical.Categorical.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> is 1D with length-<cite>K</cite>, each element is the relative
probability of sampling the class at that index.</p>
<p>If <a class="reference internal" href="#torch.distributions.categorical.Categorical.probs" title="torch.distributions.categorical.Categorical.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> is 2D, it is treated as a batch of relative probability
vectors.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><a class="reference internal" href="#torch.distributions.categorical.Categorical.probs" title="torch.distributions.categorical.Categorical.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> must be non-negative, finite and have a non-zero sum,
and it will be normalized to sum to 1.</p>
</div>
<p>See also: <a class="reference internal" href="torch.html#torch.multinomial" title="torch.multinomial"><code class="xref py py-func docutils literal notranslate"><span class="pre">torch.multinomial()</span></code></a></p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Categorical</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span> <span class="mf">0.25</span><span class="p">,</span> <span class="mf">0.25</span><span class="p">,</span> <span class="mf">0.25</span><span class="p">,</span> <span class="mf">0.25</span> <span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># equal probability of 0, 1, 2, 3</span>
<span class="go">tensor(3)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>probs</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – event probabilities</p></li>
<li><p><strong>logits</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – event log-odds</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.categorical.Categorical.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Simplex()}</em><a class="headerlink" href="#torch.distributions.categorical.Categorical.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/categorical.html#Categorical.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.categorical.Categorical.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.enumerate_support">
<code class="sig-name descname">enumerate_support</code><span class="sig-paren">(</span><em class="sig-param">expand=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/categorical.html#Categorical.enumerate_support"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.categorical.Categorical.enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/categorical.html#Categorical.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.categorical.Categorical.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.categorical.Categorical.has_enumerate_support">
<code class="sig-name descname">has_enumerate_support</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.categorical.Categorical.has_enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/categorical.html#Categorical.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.categorical.Categorical.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.categorical.Categorical.logits">
<code class="sig-name descname">logits</code><a class="reference internal" href="_modules/torch/distributions/categorical.html#Categorical.logits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.categorical.Categorical.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.categorical.Categorical.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.param_shape">
<em class="property">property </em><code class="sig-name descname">param_shape</code><a class="headerlink" href="#torch.distributions.categorical.Categorical.param_shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.categorical.Categorical.probs">
<code class="sig-name descname">probs</code><a class="reference internal" href="_modules/torch/distributions/categorical.html#Categorical.probs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.categorical.Categorical.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/categorical.html#Categorical.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.categorical.Categorical.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.categorical.Categorical.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.categorical.Categorical.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.categorical.Categorical.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="cauchy">
<h2><span class="hidden-section">Cauchy</span><a class="headerlink" href="#cauchy" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.cauchy.Cauchy">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.cauchy.</code><code class="sig-name descname">Cauchy</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">scale</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/cauchy.html#Cauchy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.cauchy.Cauchy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Samples from a Cauchy (Lorentz) distribution. The distribution of the ratio of
independent normally distributed random variables with means <cite>0</cite> follows a
Cauchy distribution.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Cauchy</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># sample from a Cauchy distribution with loc=0 and scale=1</span>
<span class="go">tensor([ 2.3214])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – mode or median of the distribution.</p></li>
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – half width at half maximum.</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.cauchy.Cauchy.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.cauchy.Cauchy.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/cauchy.html#Cauchy.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.cauchy.Cauchy.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/cauchy.html#Cauchy.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.cauchy.Cauchy.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/cauchy.html#Cauchy.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.cauchy.Cauchy.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.cauchy.Cauchy.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/cauchy.html#Cauchy.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.icdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.cauchy.Cauchy.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/cauchy.html#Cauchy.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.cauchy.Cauchy.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.cauchy.Cauchy.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/cauchy.html#Cauchy.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.cauchy.Cauchy.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.cauchy.Cauchy.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.cauchy.Cauchy.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="chi2">
<h2><span class="hidden-section">Chi2</span><a class="headerlink" href="#chi2" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.chi2.Chi2">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.chi2.</code><code class="sig-name descname">Chi2</code><span class="sig-paren">(</span><em class="sig-param">df</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/chi2.html#Chi2"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.chi2.Chi2" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.gamma.Gamma" title="torch.distributions.gamma.Gamma"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.gamma.Gamma</span></code></a></p>
<p>Creates a Chi2 distribution parameterized by shape parameter <a class="reference internal" href="#torch.distributions.chi2.Chi2.df" title="torch.distributions.chi2.Chi2.df"><code class="xref py py-attr docutils literal notranslate"><span class="pre">df</span></code></a>.
This is exactly equivalent to <code class="docutils literal notranslate"><span class="pre">Gamma(alpha=0.5*df,</span> <span class="pre">beta=0.5)</span></code></p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Chi2</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># Chi2 distributed with shape df=1</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>df</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – shape parameter of the distribution</p>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.chi2.Chi2.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'df': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.chi2.Chi2.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.chi2.Chi2.df">
<em class="property">property </em><code class="sig-name descname">df</code><a class="headerlink" href="#torch.distributions.chi2.Chi2.df" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.chi2.Chi2.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/chi2.html#Chi2.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.chi2.Chi2.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="continuousbernoulli">
<h2><span class="hidden-section">ContinuousBernoulli</span><a class="headerlink" href="#continuousbernoulli" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.continuous_bernoulli.</code><code class="sig-name descname">ContinuousBernoulli</code><span class="sig-paren">(</span><em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">lims=(0.499</em>, <em class="sig-param">0.501)</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.exp_family.ExponentialFamily" title="torch.distributions.exp_family.ExponentialFamily"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.exp_family.ExponentialFamily</span></code></a></p>
<p>Creates a continuous Bernoulli distribution parameterized by <a class="reference internal" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.probs" title="torch.distributions.continuous_bernoulli.ContinuousBernoulli.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a>
or <a class="reference internal" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.logits" title="torch.distributions.continuous_bernoulli.ContinuousBernoulli.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a> (but not both).</p>
<p>The distribution is supported in [0, 1] and parameterized by ‘probs’ (in
(0,1)) or ‘logits’ (real-valued). Note that, unlike the Bernoulli, ‘probs’
does not correspond to a probability and ‘logits’ does not correspond to
log-odds, but the same names are used due to the similarity with the
Bernoulli. See [1] for more details.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">ContinuousBernoulli</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.3</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
<span class="go">tensor([ 0.2538])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>probs</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – (0,1) valued parameters</p></li>
<li><p><strong>logits</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – real valued parameters whose sigmoid matches ‘probs’</p></li>
</ul>
</dd>
</dl>
<p>[1] The continuous Bernoulli: fixing a pervasive error in variational
autoencoders, Loaiza-Ganem G and Cunningham JP, NeurIPS 2019.
<a class="reference external" href="https://arxiv.org/abs/1907.06845">https://arxiv.org/abs/1907.06845</a></p>
<dl class="attribute">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0)}</em><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.icdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.logits">
<code class="sig-name descname">logits</code><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.logits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.param_shape">
<em class="property">property </em><code class="sig-name descname">param_shape</code><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.param_shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.probs">
<code class="sig-name descname">probs</code><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.probs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/continuous_bernoulli.html#ContinuousBernoulli.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.stddev">
<em class="property">property </em><code class="sig-name descname">stddev</code><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.stddev" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.support">
<code class="sig-name descname">support</code><em class="property"> = Interval(lower_bound=0.0, upper_bound=1.0)</em><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.continuous_bernoulli.ContinuousBernoulli.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.continuous_bernoulli.ContinuousBernoulli.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="dirichlet">
<h2><span class="hidden-section">Dirichlet</span><a class="headerlink" href="#dirichlet" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.dirichlet.Dirichlet">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.dirichlet.</code><code class="sig-name descname">Dirichlet</code><span class="sig-paren">(</span><em class="sig-param">concentration</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/dirichlet.html#Dirichlet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.exp_family.ExponentialFamily" title="torch.distributions.exp_family.ExponentialFamily"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.exp_family.ExponentialFamily</span></code></a></p>
<p>Creates a Dirichlet distribution parameterized by concentration <code class="xref py py-attr docutils literal notranslate"><span class="pre">concentration</span></code>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Dirichlet</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># Dirichlet distributed with concentrarion concentration</span>
<span class="go">tensor([ 0.1046,  0.8954])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>concentration</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – concentration parameter of the distribution
(often referred to as alpha)</p>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.dirichlet.Dirichlet.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'concentration': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.dirichlet.Dirichlet.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/dirichlet.html#Dirichlet.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.dirichlet.Dirichlet.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/dirichlet.html#Dirichlet.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.dirichlet.Dirichlet.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.dirichlet.Dirichlet.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/dirichlet.html#Dirichlet.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.dirichlet.Dirichlet.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.dirichlet.Dirichlet.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=()</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/dirichlet.html#Dirichlet.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.dirichlet.Dirichlet.support">
<code class="sig-name descname">support</code><em class="property"> = Simplex()</em><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.dirichlet.Dirichlet.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.dirichlet.Dirichlet.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="exponential">
<h2><span class="hidden-section">Exponential</span><a class="headerlink" href="#exponential" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.exponential.Exponential">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.exponential.</code><code class="sig-name descname">Exponential</code><span class="sig-paren">(</span><em class="sig-param">rate</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exponential.html#Exponential"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exponential.Exponential" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.exp_family.ExponentialFamily" title="torch.distributions.exp_family.ExponentialFamily"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.exp_family.ExponentialFamily</span></code></a></p>
<p>Creates a Exponential distribution parameterized by <code class="xref py py-attr docutils literal notranslate"><span class="pre">rate</span></code>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Exponential</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># Exponential distributed with rate=1</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>rate</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – rate = 1 / scale of the distribution</p>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.exponential.Exponential.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'rate': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.exponential.Exponential.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exponential.html#Exponential.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exponential.Exponential.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exponential.html#Exponential.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exponential.Exponential.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exponential.html#Exponential.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exponential.Exponential.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.exponential.Exponential.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.exponential.Exponential.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exponential.html#Exponential.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exponential.Exponential.icdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exponential.html#Exponential.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exponential.Exponential.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.exponential.Exponential.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/exponential.html#Exponential.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.exponential.Exponential.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.stddev">
<em class="property">property </em><code class="sig-name descname">stddev</code><a class="headerlink" href="#torch.distributions.exponential.Exponential.stddev" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.exponential.Exponential.support">
<code class="sig-name descname">support</code><em class="property"> = GreaterThan(lower_bound=0.0)</em><a class="headerlink" href="#torch.distributions.exponential.Exponential.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.exponential.Exponential.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.exponential.Exponential.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="fishersnedecor">
<h2><span class="hidden-section">FisherSnedecor</span><a class="headerlink" href="#fishersnedecor" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.fishersnedecor.</code><code class="sig-name descname">FisherSnedecor</code><span class="sig-paren">(</span><em class="sig-param">df1</em>, <em class="sig-param">df2</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/fishersnedecor.html#FisherSnedecor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a Fisher-Snedecor distribution parameterized by <code class="xref py py-attr docutils literal notranslate"><span class="pre">df1</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">df2</span></code>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">FisherSnedecor</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">2.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># Fisher-Snedecor-distributed with df1=1 and df2=2</span>
<span class="go">tensor([ 0.2453])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>df1</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – degrees of freedom parameter 1</p></li>
<li><p><strong>df2</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – degrees of freedom parameter 2</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'df1': GreaterThan(lower_bound=0.0), 'df2': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/fishersnedecor.html#FisherSnedecor.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/fishersnedecor.html#FisherSnedecor.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/fishersnedecor.html#FisherSnedecor.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor.support">
<code class="sig-name descname">support</code><em class="property"> = GreaterThan(lower_bound=0.0)</em><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.fishersnedecor.FisherSnedecor.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.fishersnedecor.FisherSnedecor.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="gamma">
<h2><span class="hidden-section">Gamma</span><a class="headerlink" href="#gamma" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.gamma.Gamma">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.gamma.</code><code class="sig-name descname">Gamma</code><span class="sig-paren">(</span><em class="sig-param">concentration</em>, <em class="sig-param">rate</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gamma.html#Gamma"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gamma.Gamma" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.exp_family.ExponentialFamily" title="torch.distributions.exp_family.ExponentialFamily"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.exp_family.ExponentialFamily</span></code></a></p>
<p>Creates a Gamma distribution parameterized by shape <code class="xref py py-attr docutils literal notranslate"><span class="pre">concentration</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">rate</span></code>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Gamma</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># Gamma distributed with concentration=1 and rate=1</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>concentration</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – shape parameter of the distribution
(often referred to as alpha)</p></li>
<li><p><strong>rate</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – rate = 1 / scale of the distribution
(often referred to as beta)</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.gamma.Gamma.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'concentration': GreaterThan(lower_bound=0.0), 'rate': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.gamma.Gamma.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gamma.Gamma.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gamma.html#Gamma.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gamma.Gamma.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gamma.Gamma.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gamma.html#Gamma.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gamma.Gamma.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.gamma.Gamma.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.gamma.Gamma.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gamma.Gamma.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gamma.html#Gamma.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gamma.Gamma.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gamma.Gamma.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.gamma.Gamma.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gamma.Gamma.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gamma.html#Gamma.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gamma.Gamma.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.gamma.Gamma.support">
<code class="sig-name descname">support</code><em class="property"> = GreaterThan(lower_bound=0.0)</em><a class="headerlink" href="#torch.distributions.gamma.Gamma.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gamma.Gamma.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.gamma.Gamma.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="geometric">
<h2><span class="hidden-section">Geometric</span><a class="headerlink" href="#geometric" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.geometric.Geometric">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.geometric.</code><code class="sig-name descname">Geometric</code><span class="sig-paren">(</span><em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/geometric.html#Geometric"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.geometric.Geometric" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a Geometric distribution parameterized by <a class="reference internal" href="#torch.distributions.geometric.Geometric.probs" title="torch.distributions.geometric.Geometric.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a>,
where <a class="reference internal" href="#torch.distributions.geometric.Geometric.probs" title="torch.distributions.geometric.Geometric.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> is the probability of success of Bernoulli trials.
It represents the probability that in <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi><mo>+</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">k + 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.77777em;vertical-align:-0.08333em;"></span><span class="mord mathdefault" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">1</span></span></span></span>

</span> Bernoulli trials, the
first <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.69444em;vertical-align:0em;"></span><span class="mord mathdefault" style="margin-right:0.03148em;">k</span></span></span></span>

</span> trials failed, before seeing a success.</p>
<p>Samples are non-negative integers [0, <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\inf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.69444em;vertical-align:0em;"></span><span class="mop">in<span style="margin-right:0.07778em;">f</span></span></span></span></span>

</span>).</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Geometric</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.3</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># underlying Bernoulli has 30% chance 1; 70% chance 0</span>
<span class="go">tensor([ 2.])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>probs</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the probability of sampling <cite>1</cite>. Must be in range (0, 1]</p></li>
<li><p><strong>logits</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the log-odds of sampling <cite>1</cite>.</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.geometric.Geometric.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0)}</em><a class="headerlink" href="#torch.distributions.geometric.Geometric.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.geometric.Geometric.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/geometric.html#Geometric.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.geometric.Geometric.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.geometric.Geometric.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/geometric.html#Geometric.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.geometric.Geometric.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.geometric.Geometric.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/geometric.html#Geometric.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.geometric.Geometric.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.geometric.Geometric.logits">
<code class="sig-name descname">logits</code><a class="reference internal" href="_modules/torch/distributions/geometric.html#Geometric.logits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.geometric.Geometric.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.geometric.Geometric.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.geometric.Geometric.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.geometric.Geometric.probs">
<code class="sig-name descname">probs</code><a class="reference internal" href="_modules/torch/distributions/geometric.html#Geometric.probs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.geometric.Geometric.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.geometric.Geometric.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/geometric.html#Geometric.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.geometric.Geometric.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.geometric.Geometric.support">
<code class="sig-name descname">support</code><em class="property"> = IntegerGreaterThan(lower_bound=0)</em><a class="headerlink" href="#torch.distributions.geometric.Geometric.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.geometric.Geometric.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.geometric.Geometric.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="gumbel">
<h2><span class="hidden-section">Gumbel</span><a class="headerlink" href="#gumbel" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.gumbel.Gumbel">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.gumbel.</code><code class="sig-name descname">Gumbel</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">scale</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gumbel.html#Gumbel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gumbel.Gumbel" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.transformed_distribution.TransformedDistribution</span></code></a></p>
<p>Samples from a Gumbel Distribution.</p>
<p>Examples:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Gumbel</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">2.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># sample from Gumbel distribution with loc=1, scale=2</span>
<span class="go">tensor([ 1.0124])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Location parameter of the distribution</p></li>
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Scale parameter of the distribution</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.gumbel.Gumbel.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.gumbel.Gumbel.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gumbel.Gumbel.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gumbel.html#Gumbel.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gumbel.Gumbel.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gumbel.Gumbel.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gumbel.html#Gumbel.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gumbel.Gumbel.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gumbel.Gumbel.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/gumbel.html#Gumbel.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.gumbel.Gumbel.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gumbel.Gumbel.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.gumbel.Gumbel.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gumbel.Gumbel.stddev">
<em class="property">property </em><code class="sig-name descname">stddev</code><a class="headerlink" href="#torch.distributions.gumbel.Gumbel.stddev" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.gumbel.Gumbel.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.gumbel.Gumbel.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.gumbel.Gumbel.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.gumbel.Gumbel.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="halfcauchy">
<h2><span class="hidden-section">HalfCauchy</span><a class="headerlink" href="#halfcauchy" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.half_cauchy.HalfCauchy">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.half_cauchy.</code><code class="sig-name descname">HalfCauchy</code><span class="sig-paren">(</span><em class="sig-param">scale</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_cauchy.html#HalfCauchy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.transformed_distribution.TransformedDistribution</span></code></a></p>
<p>Creates a half-normal distribution parameterized by <cite>scale</cite> where:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">X</span> <span class="o">~</span> <span class="n">Cauchy</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">scale</span><span class="p">)</span>
<span class="n">Y</span> <span class="o">=</span> <span class="o">|</span><span class="n">X</span><span class="o">|</span> <span class="o">~</span> <span class="n">HalfCauchy</span><span class="p">(</span><span class="n">scale</span><span class="p">)</span>
</pre></div>
</div>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">HalfCauchy</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># half-cauchy distributed with scale=1</span>
<span class="go">tensor([ 2.3214])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – scale of the full Cauchy distribution</p>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.half_cauchy.HalfCauchy.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_cauchy.HalfCauchy.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_cauchy.html#HalfCauchy.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_cauchy.HalfCauchy.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_cauchy.html#HalfCauchy.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_cauchy.HalfCauchy.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_cauchy.html#HalfCauchy.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.half_cauchy.HalfCauchy.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_cauchy.HalfCauchy.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">prob</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_cauchy.html#HalfCauchy.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.icdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_cauchy.HalfCauchy.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_cauchy.html#HalfCauchy.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_cauchy.HalfCauchy.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_cauchy.HalfCauchy.scale">
<em class="property">property </em><code class="sig-name descname">scale</code><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.scale" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.half_cauchy.HalfCauchy.support">
<code class="sig-name descname">support</code><em class="property"> = GreaterThan(lower_bound=0.0)</em><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_cauchy.HalfCauchy.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.half_cauchy.HalfCauchy.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="halfnormal">
<h2><span class="hidden-section">HalfNormal</span><a class="headerlink" href="#halfnormal" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.half_normal.HalfNormal">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.half_normal.</code><code class="sig-name descname">HalfNormal</code><span class="sig-paren">(</span><em class="sig-param">scale</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_normal.html#HalfNormal"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.transformed_distribution.TransformedDistribution</span></code></a></p>
<p>Creates a half-normal distribution parameterized by <cite>scale</cite> where:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">X</span> <span class="o">~</span> <span class="n">Normal</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">scale</span><span class="p">)</span>
<span class="n">Y</span> <span class="o">=</span> <span class="o">|</span><span class="n">X</span><span class="o">|</span> <span class="o">~</span> <span class="n">HalfNormal</span><span class="p">(</span><span class="n">scale</span><span class="p">)</span>
</pre></div>
</div>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">HalfNormal</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># half-normal distributed with scale=1</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – scale of the full Normal distribution</p>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.half_normal.HalfNormal.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_normal.HalfNormal.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_normal.html#HalfNormal.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_normal.HalfNormal.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_normal.html#HalfNormal.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_normal.HalfNormal.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_normal.html#HalfNormal.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.half_normal.HalfNormal.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_normal.HalfNormal.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">prob</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_normal.html#HalfNormal.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.icdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_normal.HalfNormal.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/half_normal.html#HalfNormal.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_normal.HalfNormal.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_normal.HalfNormal.scale">
<em class="property">property </em><code class="sig-name descname">scale</code><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.scale" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.half_normal.HalfNormal.support">
<code class="sig-name descname">support</code><em class="property"> = GreaterThan(lower_bound=0.0)</em><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.half_normal.HalfNormal.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.half_normal.HalfNormal.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="independent">
<h2><span class="hidden-section">Independent</span><a class="headerlink" href="#independent" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.independent.Independent">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.independent.</code><code class="sig-name descname">Independent</code><span class="sig-paren">(</span><em class="sig-param">base_distribution</em>, <em class="sig-param">reinterpreted_batch_ndims</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/independent.html#Independent"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.independent.Independent" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Reinterprets some of the batch dims of a distribution as event dims.</p>
<p>This is mainly useful for changing the shape of the result of
<a class="reference internal" href="#torch.distributions.independent.Independent.log_prob" title="torch.distributions.independent.Independent.log_prob"><code class="xref py py-meth docutils literal notranslate"><span class="pre">log_prob()</span></code></a>. For example to create a diagonal Normal distribution with
the same shape as a Multivariate Normal distribution (so they are
interchangeable), you can:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">loc</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">scale</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mvn</span> <span class="o">=</span> <span class="n">MultivariateNormal</span><span class="p">(</span><span class="n">loc</span><span class="p">,</span> <span class="n">scale_tril</span><span class="o">=</span><span class="n">torch</span><span class="o">.</span><span class="n">diag</span><span class="p">(</span><span class="n">scale</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="n">mvn</span><span class="o">.</span><span class="n">batch_shape</span><span class="p">,</span> <span class="n">mvn</span><span class="o">.</span><span class="n">event_shape</span><span class="p">]</span>
<span class="go">[torch.Size(()), torch.Size((3,))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normal</span> <span class="o">=</span> <span class="n">Normal</span><span class="p">(</span><span class="n">loc</span><span class="p">,</span> <span class="n">scale</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="n">normal</span><span class="o">.</span><span class="n">batch_shape</span><span class="p">,</span> <span class="n">normal</span><span class="o">.</span><span class="n">event_shape</span><span class="p">]</span>
<span class="go">[torch.Size((3,)), torch.Size(())]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">diagn</span> <span class="o">=</span> <span class="n">Independent</span><span class="p">(</span><span class="n">normal</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="n">diagn</span><span class="o">.</span><span class="n">batch_shape</span><span class="p">,</span> <span class="n">diagn</span><span class="o">.</span><span class="n">event_shape</span><span class="p">]</span>
<span class="go">[torch.Size(()), torch.Size((3,))]</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>base_distribution</strong> (<a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><em>torch.distributions.distribution.Distribution</em></a>) – a
base distribution</p></li>
<li><p><strong>reinterpreted_batch_ndims</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – the number of batch dims to
reinterpret as event dims</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.independent.Independent.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {}</em><a class="headerlink" href="#torch.distributions.independent.Independent.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/independent.html#Independent.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.independent.Independent.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.enumerate_support">
<code class="sig-name descname">enumerate_support</code><span class="sig-paren">(</span><em class="sig-param">expand=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/independent.html#Independent.enumerate_support"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.independent.Independent.enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/independent.html#Independent.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.independent.Independent.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.has_enumerate_support">
<em class="property">property </em><code class="sig-name descname">has_enumerate_support</code><a class="headerlink" href="#torch.distributions.independent.Independent.has_enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.has_rsample">
<em class="property">property </em><code class="sig-name descname">has_rsample</code><a class="headerlink" href="#torch.distributions.independent.Independent.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/independent.html#Independent.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.independent.Independent.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.independent.Independent.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/independent.html#Independent.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.independent.Independent.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/independent.html#Independent.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.independent.Independent.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.independent.Independent.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.independent.Independent.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.independent.Independent.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="laplace">
<h2><span class="hidden-section">Laplace</span><a class="headerlink" href="#laplace" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.laplace.Laplace">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.laplace.</code><code class="sig-name descname">Laplace</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">scale</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/laplace.html#Laplace"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.laplace.Laplace" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a Laplace distribution parameterized by <code class="xref py py-attr docutils literal notranslate"><span class="pre">loc</span></code> and :attr:’scale’.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Laplace</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># Laplace distributed with loc=0, scale=1</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – mean of the distribution</p></li>
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – scale of the distribution</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.laplace.Laplace.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.laplace.Laplace.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/laplace.html#Laplace.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.laplace.Laplace.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/laplace.html#Laplace.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.laplace.Laplace.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/laplace.html#Laplace.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.laplace.Laplace.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.laplace.Laplace.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.laplace.Laplace.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/laplace.html#Laplace.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.laplace.Laplace.icdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/laplace.html#Laplace.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.laplace.Laplace.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.laplace.Laplace.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/laplace.html#Laplace.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.laplace.Laplace.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.stddev">
<em class="property">property </em><code class="sig-name descname">stddev</code><a class="headerlink" href="#torch.distributions.laplace.Laplace.stddev" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.laplace.Laplace.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.laplace.Laplace.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.laplace.Laplace.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.laplace.Laplace.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="lognormal">
<h2><span class="hidden-section">LogNormal</span><a class="headerlink" href="#lognormal" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.log_normal.LogNormal">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.log_normal.</code><code class="sig-name descname">LogNormal</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">scale</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/log_normal.html#LogNormal"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.log_normal.LogNormal" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.transformed_distribution.TransformedDistribution</span></code></a></p>
<p>Creates a log-normal distribution parameterized by
<a class="reference internal" href="#torch.distributions.log_normal.LogNormal.loc" title="torch.distributions.log_normal.LogNormal.loc"><code class="xref py py-attr docutils literal notranslate"><span class="pre">loc</span></code></a> and <a class="reference internal" href="#torch.distributions.log_normal.LogNormal.scale" title="torch.distributions.log_normal.LogNormal.scale"><code class="xref py py-attr docutils literal notranslate"><span class="pre">scale</span></code></a> where:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">X</span> <span class="o">~</span> <span class="n">Normal</span><span class="p">(</span><span class="n">loc</span><span class="p">,</span> <span class="n">scale</span><span class="p">)</span>
<span class="n">Y</span> <span class="o">=</span> <span class="n">exp</span><span class="p">(</span><span class="n">X</span><span class="p">)</span> <span class="o">~</span> <span class="n">LogNormal</span><span class="p">(</span><span class="n">loc</span><span class="p">,</span> <span class="n">scale</span><span class="p">)</span>
</pre></div>
</div>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">LogNormal</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># log-normal distributed with mean=0 and stddev=1</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – mean of log of distribution</p></li>
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – standard deviation of log of the distribution</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.log_normal.LogNormal.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.log_normal.LogNormal.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/log_normal.html#LogNormal.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.log_normal.LogNormal.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/log_normal.html#LogNormal.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.log_normal.LogNormal.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.log_normal.LogNormal.loc">
<em class="property">property </em><code class="sig-name descname">loc</code><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.loc" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.log_normal.LogNormal.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.log_normal.LogNormal.scale">
<em class="property">property </em><code class="sig-name descname">scale</code><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.scale" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.log_normal.LogNormal.support">
<code class="sig-name descname">support</code><em class="property"> = GreaterThan(lower_bound=0.0)</em><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.log_normal.LogNormal.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.log_normal.LogNormal.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="lowrankmultivariatenormal">
<h2><span class="hidden-section">LowRankMultivariateNormal</span><a class="headerlink" href="#lowrankmultivariatenormal" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.lowrank_multivariate_normal.</code><code class="sig-name descname">LowRankMultivariateNormal</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">cov_factor</em>, <em class="sig-param">cov_diag</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a multivariate normal distribution with covariance matrix having a low-rank form
parameterized by <code class="xref py py-attr docutils literal notranslate"><span class="pre">cov_factor</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">cov_diag</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">covariance_matrix</span> <span class="o">=</span> <span class="n">cov_factor</span> <span class="o">@</span> <span class="n">cov_factor</span><span class="o">.</span><span class="n">T</span> <span class="o">+</span> <span class="n">cov_diag</span>
</pre></div>
</div>
<p class="rubric">Example</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">LowRankMultivariateNormal</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([[</span><span class="mf">1.</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.</span><span class="p">]]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># normally distributed with mean=`[0,0]`, cov_factor=`[[1],[0]]`, cov_diag=`[1,1]`</span>
<span class="go">tensor([-0.2102, -0.5429])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – mean of the distribution with shape <cite>batch_shape + event_shape</cite></p></li>
<li><p><strong>cov_factor</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – factor part of low-rank form of covariance matrix with shape
<cite>batch_shape + event_shape + (rank,)</cite></p></li>
<li><p><strong>cov_diag</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – diagonal part of low-rank form of covariance matrix with shape
<cite>batch_shape + event_shape</cite></p></li>
</ul>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The computation for determinant and inverse of covariance matrix is avoided when
<cite>cov_factor.shape[1] &lt;&lt; cov_factor.shape[0]</cite> thanks to <a class="reference external" href="https://en.wikipedia.org/wiki/Woodbury_matrix_identity">Woodbury matrix identity</a> and
<a class="reference external" href="https://en.wikipedia.org/wiki/Matrix_determinant_lemma">matrix determinant lemma</a>.
Thanks to these formulas, we just need to compute the determinant and inverse of
the small size “capacitance” matrix:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">capacitance</span> <span class="o">=</span> <span class="n">I</span> <span class="o">+</span> <span class="n">cov_factor</span><span class="o">.</span><span class="n">T</span> <span class="o">@</span> <span class="n">inv</span><span class="p">(</span><span class="n">cov_diag</span><span class="p">)</span> <span class="o">@</span> <span class="n">cov_factor</span>
</pre></div>
</div>
</div>
<dl class="attribute">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'cov_diag': GreaterThan(lower_bound=0.0), 'cov_factor': Real(), 'loc': Real()}</em><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.covariance_matrix">
<code class="sig-name descname">covariance_matrix</code><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal.covariance_matrix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.covariance_matrix" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.precision_matrix">
<code class="sig-name descname">precision_matrix</code><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal.precision_matrix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.precision_matrix" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.scale_tril">
<code class="sig-name descname">scale_tril</code><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal.scale_tril"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.scale_tril" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.variance">
<code class="sig-name descname">variance</code><a class="reference internal" href="_modules/torch/distributions/lowrank_multivariate_normal.html#LowRankMultivariateNormal.variance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.lowrank_multivariate_normal.LowRankMultivariateNormal.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="mixturesamefamily">
<h2><span class="hidden-section">MixtureSameFamily</span><a class="headerlink" href="#mixturesamefamily" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.mixture_same_family.</code><code class="sig-name descname">MixtureSameFamily</code><span class="sig-paren">(</span><em class="sig-param">mixture_distribution</em>, <em class="sig-param">component_distribution</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/mixture_same_family.html#MixtureSameFamily"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>The <cite>MixtureSameFamily</cite> distribution implements a (batch of) mixture
distribution where all component are from different parameterizations of
the same distribution type. It is parameterized by a <cite>Categorical</cite>
“selecting distribution” (over <cite>k</cite> component) and a component
distribution, i.e., a <cite>Distribution</cite> with a rightmost batch shape
(equal to <cite>[k]</cite>) which indexes each (batch of) component.</p>
<p>Examples:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># Construct Gaussian Mixture Model in 1D consisting of 5 equally</span>
<span class="c1"># weighted normal distributions</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">mix</span> <span class="o">=</span> <span class="n">D</span><span class="o">.</span><span class="n">Categorical</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">5</span><span class="p">,))</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">comp</span> <span class="o">=</span> <span class="n">D</span><span class="o">.</span><span class="n">Normal</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="mi">5</span><span class="p">,),</span> <span class="n">torch</span><span class="o">.</span><span class="n">rand</span><span class="p">(</span><span class="mi">5</span><span class="p">,))</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">gmm</span> <span class="o">=</span> <span class="n">MixtureSameFamily</span><span class="p">(</span><span class="n">mix</span><span class="p">,</span> <span class="n">comp</span><span class="p">)</span>

<span class="c1"># Construct Gaussian Mixture Modle in 2D consisting of 5 equally</span>
<span class="c1"># weighted bivariate normal distributions</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">mix</span> <span class="o">=</span> <span class="n">D</span><span class="o">.</span><span class="n">Categorical</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">5</span><span class="p">,))</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">comp</span> <span class="o">=</span> <span class="n">D</span><span class="o">.</span><span class="n">Independent</span><span class="p">(</span><span class="n">D</span><span class="o">.</span><span class="n">Normal</span><span class="p">(</span>
             <span class="n">torch</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="n">torch</span><span class="o">.</span><span class="n">rand</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)),</span> <span class="mi">1</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">gmm</span> <span class="o">=</span> <span class="n">MixtureSameFamily</span><span class="p">(</span><span class="n">mix</span><span class="p">,</span> <span class="n">comp</span><span class="p">)</span>

<span class="c1"># Construct a batch of 3 Gaussian Mixture Models in 2D each</span>
<span class="c1"># consisting of 5 random weighted bivariate normal distributions</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">mix</span> <span class="o">=</span> <span class="n">D</span><span class="o">.</span><span class="n">Categorical</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">rand</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">5</span><span class="p">))</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">comp</span> <span class="o">=</span> <span class="n">D</span><span class="o">.</span><span class="n">Independent</span><span class="p">(</span><span class="n">D</span><span class="o">.</span><span class="n">Normal</span><span class="p">(</span>
            <span class="n">torch</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="n">torch</span><span class="o">.</span><span class="n">rand</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)),</span> <span class="mi">1</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">gmm</span> <span class="o">=</span> <span class="n">MixtureSameFamily</span><span class="p">(</span><span class="n">mix</span><span class="p">,</span> <span class="n">comp</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mixture_distribution</strong> – <cite>torch.distributions.Categorical</cite>-like
instance. Manages the probability of selecting component.
The number of categories must match the rightmost batch
dimension of the <cite>component_distribution</cite>. Must have either
scalar <cite>batch_shape</cite> or <cite>batch_shape</cite> matching
<cite>component_distribution.batch_shape[:-1]</cite></p></li>
<li><p><strong>component_distribution</strong> – <cite>torch.distributions.Distribution</cite>-like
instance. Right-most batch dimension indexes component.</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {}</em><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/mixture_same_family.html#MixtureSameFamily.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.component_distribution">
<em class="property">property </em><code class="sig-name descname">component_distribution</code><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.component_distribution" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/mixture_same_family.html#MixtureSameFamily.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = False</em><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/mixture_same_family.html#MixtureSameFamily.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.mixture_distribution">
<em class="property">property </em><code class="sig-name descname">mixture_distribution</code><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.mixture_distribution" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/mixture_same_family.html#MixtureSameFamily.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.mixture_same_family.MixtureSameFamily.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.mixture_same_family.MixtureSameFamily.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="multinomial">
<h2><span class="hidden-section">Multinomial</span><a class="headerlink" href="#multinomial" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.multinomial.Multinomial">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.multinomial.</code><code class="sig-name descname">Multinomial</code><span class="sig-paren">(</span><em class="sig-param">total_count=1</em>, <em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multinomial.html#Multinomial"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multinomial.Multinomial" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a Multinomial distribution parameterized by <code class="xref py py-attr docutils literal notranslate"><span class="pre">total_count</span></code> and
either <a class="reference internal" href="#torch.distributions.multinomial.Multinomial.probs" title="torch.distributions.multinomial.Multinomial.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> or <a class="reference internal" href="#torch.distributions.multinomial.Multinomial.logits" title="torch.distributions.multinomial.Multinomial.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a> (but not both). The innermost dimension of
<a class="reference internal" href="#torch.distributions.multinomial.Multinomial.probs" title="torch.distributions.multinomial.Multinomial.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> indexes over categories. All other dimensions index over batches.</p>
<p>Note that <code class="xref py py-attr docutils literal notranslate"><span class="pre">total_count</span></code> need not be specified if only <a class="reference internal" href="#torch.distributions.multinomial.Multinomial.log_prob" title="torch.distributions.multinomial.Multinomial.log_prob"><code class="xref py py-meth docutils literal notranslate"><span class="pre">log_prob()</span></code></a> is
called (see example below)</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><a class="reference internal" href="#torch.distributions.multinomial.Multinomial.probs" title="torch.distributions.multinomial.Multinomial.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> must be non-negative, finite and have a non-zero sum,
and it will be normalized to sum to 1.</p>
</div>
<ul class="simple">
<li><p><a class="reference internal" href="#torch.distributions.multinomial.Multinomial.sample" title="torch.distributions.multinomial.Multinomial.sample"><code class="xref py py-meth docutils literal notranslate"><span class="pre">sample()</span></code></a> requires a single shared <cite>total_count</cite> for all
parameters and samples.</p></li>
<li><p><a class="reference internal" href="#torch.distributions.multinomial.Multinomial.log_prob" title="torch.distributions.multinomial.Multinomial.log_prob"><code class="xref py py-meth docutils literal notranslate"><span class="pre">log_prob()</span></code></a> allows different <cite>total_count</cite> for each parameter and
sample.</p></li>
</ul>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Multinomial</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span> <span class="mf">1.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># equal probability of 0, 1, 2, 3</span>
<span class="go">tensor([ 21.,  24.,  30.,  25.])</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">Multinomial</span><span class="p">(</span><span class="n">probs</span><span class="o">=</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">]))</span><span class="o">.</span><span class="n">log_prob</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">tensor([-4.1338])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>total_count</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – number of trials</p></li>
<li><p><strong>probs</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – event probabilities</p></li>
<li><p><strong>logits</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – event log probabilities</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.multinomial.Multinomial.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Simplex()}</em><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multinomial.html#Multinomial.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multinomial.html#Multinomial.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.logits">
<em class="property">property </em><code class="sig-name descname">logits</code><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.param_shape">
<em class="property">property </em><code class="sig-name descname">param_shape</code><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.param_shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.probs">
<em class="property">property </em><code class="sig-name descname">probs</code><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multinomial.html#Multinomial.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multinomial.Multinomial.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.multinomial.Multinomial.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="multivariatenormal">
<h2><span class="hidden-section">MultivariateNormal</span><a class="headerlink" href="#multivariatenormal" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.multivariate_normal.</code><code class="sig-name descname">MultivariateNormal</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">covariance_matrix=None</em>, <em class="sig-param">precision_matrix=None</em>, <em class="sig-param">scale_tril=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multivariate_normal.html#MultivariateNormal"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a multivariate normal (also called Gaussian) distribution
parameterized by a mean vector and a covariance matrix.</p>
<p>The multivariate normal distribution can be parameterized either
in terms of a positive definite covariance matrix <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">Σ</mi></mrow><annotation encoding="application/x-tex">\mathbf{\Sigma}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.68611em;vertical-align:0em;"></span><span class="mord"><span class="mord mathbf">Σ</span></span></span></span></span>

</span>
or a positive definite precision matrix <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi mathvariant="bold">Σ</mi><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow><annotation encoding="application/x-tex">\mathbf{\Sigma}^{-1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141079999999999em;vertical-align:0em;"></span><span class="mord"><span class="mord"><span class="mord mathbf">Σ</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141079999999999em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span></span>

</span>
or a lower-triangular matrix <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">L</mi></mrow><annotation encoding="application/x-tex">\mathbf{L}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.68611em;vertical-align:0em;"></span><span class="mord"><span class="mord mathbf">L</span></span></span></span></span>

</span> with positive-valued
diagonal entries, such that
<span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">Σ</mi><mo>=</mo><mi mathvariant="bold">L</mi><msup><mi mathvariant="bold">L</mi><mi mathvariant="normal">⊤</mi></msup></mrow><annotation encoding="application/x-tex">\mathbf{\Sigma} = \mathbf{L}\mathbf{L}^\top</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.68611em;vertical-align:0em;"></span><span class="mord"><span class="mord mathbf">Σ</span></span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:0.849108em;vertical-align:0em;"></span><span class="mord"><span class="mord mathbf">L</span></span><span class="mord"><span class="mord"><span class="mord mathbf">L</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.849108em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">⊤</span></span></span></span></span></span></span></span></span></span></span>

</span>. This triangular matrix
can be obtained via e.g. Cholesky decomposition of the covariance.</p>
<p class="rubric">Example</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">MultivariateNormal</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">torch</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># normally distributed with mean=`[0,0]` and covariance_matrix=`I`</span>
<span class="go">tensor([-0.2102, -0.5429])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – mean of the distribution</p></li>
<li><p><strong>covariance_matrix</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – positive-definite covariance matrix</p></li>
<li><p><strong>precision_matrix</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – positive-definite precision matrix</p></li>
<li><p><strong>scale_tril</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – lower-triangular factor of covariance, with positive-valued diagonal</p></li>
</ul>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Only one of <a class="reference internal" href="#torch.distributions.multivariate_normal.MultivariateNormal.covariance_matrix" title="torch.distributions.multivariate_normal.MultivariateNormal.covariance_matrix"><code class="xref py py-attr docutils literal notranslate"><span class="pre">covariance_matrix</span></code></a> or <a class="reference internal" href="#torch.distributions.multivariate_normal.MultivariateNormal.precision_matrix" title="torch.distributions.multivariate_normal.MultivariateNormal.precision_matrix"><code class="xref py py-attr docutils literal notranslate"><span class="pre">precision_matrix</span></code></a> or
<a class="reference internal" href="#torch.distributions.multivariate_normal.MultivariateNormal.scale_tril" title="torch.distributions.multivariate_normal.MultivariateNormal.scale_tril"><code class="xref py py-attr docutils literal notranslate"><span class="pre">scale_tril</span></code></a> can be specified.</p>
<p>Using <a class="reference internal" href="#torch.distributions.multivariate_normal.MultivariateNormal.scale_tril" title="torch.distributions.multivariate_normal.MultivariateNormal.scale_tril"><code class="xref py py-attr docutils literal notranslate"><span class="pre">scale_tril</span></code></a> will be more efficient: all computations internally
are based on <a class="reference internal" href="#torch.distributions.multivariate_normal.MultivariateNormal.scale_tril" title="torch.distributions.multivariate_normal.MultivariateNormal.scale_tril"><code class="xref py py-attr docutils literal notranslate"><span class="pre">scale_tril</span></code></a>. If <a class="reference internal" href="#torch.distributions.multivariate_normal.MultivariateNormal.covariance_matrix" title="torch.distributions.multivariate_normal.MultivariateNormal.covariance_matrix"><code class="xref py py-attr docutils literal notranslate"><span class="pre">covariance_matrix</span></code></a> or
<a class="reference internal" href="#torch.distributions.multivariate_normal.MultivariateNormal.precision_matrix" title="torch.distributions.multivariate_normal.MultivariateNormal.precision_matrix"><code class="xref py py-attr docutils literal notranslate"><span class="pre">precision_matrix</span></code></a> is passed instead, it is only used to compute
the corresponding lower triangular matrices using a Cholesky decomposition.</p>
</div>
<dl class="attribute">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'covariance_matrix': PositiveDefinite(), 'loc': RealVector(), 'precision_matrix': PositiveDefinite(), 'scale_tril': LowerCholesky()}</em><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.covariance_matrix">
<code class="sig-name descname">covariance_matrix</code><a class="reference internal" href="_modules/torch/distributions/multivariate_normal.html#MultivariateNormal.covariance_matrix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.covariance_matrix" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multivariate_normal.html#MultivariateNormal.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multivariate_normal.html#MultivariateNormal.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multivariate_normal.html#MultivariateNormal.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.precision_matrix">
<code class="sig-name descname">precision_matrix</code><a class="reference internal" href="_modules/torch/distributions/multivariate_normal.html#MultivariateNormal.precision_matrix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.precision_matrix" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/multivariate_normal.html#MultivariateNormal.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.scale_tril">
<code class="sig-name descname">scale_tril</code><a class="reference internal" href="_modules/torch/distributions/multivariate_normal.html#MultivariateNormal.scale_tril"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.scale_tril" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.multivariate_normal.MultivariateNormal.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.multivariate_normal.MultivariateNormal.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="negativebinomial">
<h2><span class="hidden-section">NegativeBinomial</span><a class="headerlink" href="#negativebinomial" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.negative_binomial.NegativeBinomial">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.negative_binomial.</code><code class="sig-name descname">NegativeBinomial</code><span class="sig-paren">(</span><em class="sig-param">total_count</em>, <em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/negative_binomial.html#NegativeBinomial"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a Negative Binomial distribution, i.e. distribution
of the number of successful independent and identical Bernoulli trials
before <code class="xref py py-attr docutils literal notranslate"><span class="pre">total_count</span></code> failures are achieved. The probability
of success of each Bernoulli trial is <a class="reference internal" href="#torch.distributions.negative_binomial.NegativeBinomial.probs" title="torch.distributions.negative_binomial.NegativeBinomial.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>total_count</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – non-negative number of negative Bernoulli
trials to stop, although the distribution is still valid for real
valued count</p></li>
<li><p><strong>probs</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Event probabilities of success in the half open interval [0, 1)</p></li>
<li><p><strong>logits</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Event log-odds for probabilities of success</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': HalfOpenInterval(lower_bound=0.0, upper_bound=1.0), 'total_count': GreaterThanEq(lower_bound=0)}</em><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/negative_binomial.html#NegativeBinomial.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/negative_binomial.html#NegativeBinomial.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.logits">
<code class="sig-name descname">logits</code><a class="reference internal" href="_modules/torch/distributions/negative_binomial.html#NegativeBinomial.logits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.param_shape">
<em class="property">property </em><code class="sig-name descname">param_shape</code><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.param_shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.probs">
<code class="sig-name descname">probs</code><a class="reference internal" href="_modules/torch/distributions/negative_binomial.html#NegativeBinomial.probs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/negative_binomial.html#NegativeBinomial.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.support">
<code class="sig-name descname">support</code><em class="property"> = IntegerGreaterThan(lower_bound=0)</em><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.negative_binomial.NegativeBinomial.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.negative_binomial.NegativeBinomial.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="normal">
<h2><span class="hidden-section">Normal</span><a class="headerlink" href="#normal" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.normal.Normal">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.normal.</code><code class="sig-name descname">Normal</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">scale</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/normal.html#Normal"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.normal.Normal" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.exp_family.ExponentialFamily" title="torch.distributions.exp_family.ExponentialFamily"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.exp_family.ExponentialFamily</span></code></a></p>
<p>Creates a normal (also called Gaussian) distribution parameterized by
<code class="xref py py-attr docutils literal notranslate"><span class="pre">loc</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">scale</span></code>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Normal</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># normally distributed with loc=0 and scale=1</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – mean of the distribution (often referred to as mu)</p></li>
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – standard deviation of the distribution
(often referred to as sigma)</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.normal.Normal.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.normal.Normal.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/normal.html#Normal.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.normal.Normal.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/normal.html#Normal.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.normal.Normal.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/normal.html#Normal.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.normal.Normal.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.normal.Normal.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.normal.Normal.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/normal.html#Normal.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.normal.Normal.icdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/normal.html#Normal.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.normal.Normal.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.normal.Normal.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/normal.html#Normal.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.normal.Normal.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/normal.html#Normal.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.normal.Normal.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.stddev">
<em class="property">property </em><code class="sig-name descname">stddev</code><a class="headerlink" href="#torch.distributions.normal.Normal.stddev" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.normal.Normal.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.normal.Normal.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.normal.Normal.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.normal.Normal.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="onehotcategorical">
<h2><span class="hidden-section">OneHotCategorical</span><a class="headerlink" href="#onehotcategorical" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.one_hot_categorical.</code><code class="sig-name descname">OneHotCategorical</code><span class="sig-paren">(</span><em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/one_hot_categorical.html#OneHotCategorical"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a one-hot categorical distribution parameterized by <a class="reference internal" href="#torch.distributions.one_hot_categorical.OneHotCategorical.probs" title="torch.distributions.one_hot_categorical.OneHotCategorical.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> or
<a class="reference internal" href="#torch.distributions.one_hot_categorical.OneHotCategorical.logits" title="torch.distributions.one_hot_categorical.OneHotCategorical.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a>.</p>
<p>Samples are one-hot coded vectors of size <code class="docutils literal notranslate"><span class="pre">probs.size(-1)</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><a class="reference internal" href="#torch.distributions.one_hot_categorical.OneHotCategorical.probs" title="torch.distributions.one_hot_categorical.OneHotCategorical.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> must be non-negative, finite and have a non-zero sum,
and it will be normalized to sum to 1.</p>
</div>
<p>See also: <code class="xref py py-func docutils literal notranslate"><span class="pre">torch.distributions.Categorical()</span></code> for specifications of
<a class="reference internal" href="#torch.distributions.one_hot_categorical.OneHotCategorical.probs" title="torch.distributions.one_hot_categorical.OneHotCategorical.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> and <a class="reference internal" href="#torch.distributions.one_hot_categorical.OneHotCategorical.logits" title="torch.distributions.one_hot_categorical.OneHotCategorical.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">OneHotCategorical</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span> <span class="mf">0.25</span><span class="p">,</span> <span class="mf">0.25</span><span class="p">,</span> <span class="mf">0.25</span><span class="p">,</span> <span class="mf">0.25</span> <span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># equal probability of 0, 1, 2, 3</span>
<span class="go">tensor([ 0.,  0.,  0.,  1.])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>probs</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – event probabilities</p></li>
<li><p><strong>logits</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – event log probabilities</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Simplex()}</em><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/one_hot_categorical.html#OneHotCategorical.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.enumerate_support">
<code class="sig-name descname">enumerate_support</code><span class="sig-paren">(</span><em class="sig-param">expand=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/one_hot_categorical.html#OneHotCategorical.enumerate_support"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/one_hot_categorical.html#OneHotCategorical.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.has_enumerate_support">
<code class="sig-name descname">has_enumerate_support</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.has_enumerate_support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/one_hot_categorical.html#OneHotCategorical.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.logits">
<em class="property">property </em><code class="sig-name descname">logits</code><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.param_shape">
<em class="property">property </em><code class="sig-name descname">param_shape</code><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.param_shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.probs">
<em class="property">property </em><code class="sig-name descname">probs</code><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/one_hot_categorical.html#OneHotCategorical.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.support">
<code class="sig-name descname">support</code><em class="property"> = Simplex()</em><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.one_hot_categorical.OneHotCategorical.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.one_hot_categorical.OneHotCategorical.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="pareto">
<h2><span class="hidden-section">Pareto</span><a class="headerlink" href="#pareto" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.pareto.Pareto">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.pareto.</code><code class="sig-name descname">Pareto</code><span class="sig-paren">(</span><em class="sig-param">scale</em>, <em class="sig-param">alpha</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/pareto.html#Pareto"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.pareto.Pareto" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.transformed_distribution.TransformedDistribution</span></code></a></p>
<p>Samples from a Pareto Type 1 distribution.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Pareto</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># sample from a Pareto distribution with scale=1 and alpha=1</span>
<span class="go">tensor([ 1.5623])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Scale parameter of the distribution</p></li>
<li><p><strong>alpha</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Shape parameter of the distribution</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.pareto.Pareto.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'alpha': GreaterThan(lower_bound=0.0), 'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.pareto.Pareto.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.pareto.Pareto.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/pareto.html#Pareto.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.pareto.Pareto.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.pareto.Pareto.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/pareto.html#Pareto.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.pareto.Pareto.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.pareto.Pareto.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.pareto.Pareto.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.pareto.Pareto.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.pareto.Pareto.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.pareto.Pareto.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.pareto.Pareto.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="poisson">
<h2><span class="hidden-section">Poisson</span><a class="headerlink" href="#poisson" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.poisson.Poisson">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.poisson.</code><code class="sig-name descname">Poisson</code><span class="sig-paren">(</span><em class="sig-param">rate</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/poisson.html#Poisson"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.poisson.Poisson" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.exp_family.ExponentialFamily" title="torch.distributions.exp_family.ExponentialFamily"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.exp_family.ExponentialFamily</span></code></a></p>
<p>Creates a Poisson distribution parameterized by <code class="xref py py-attr docutils literal notranslate"><span class="pre">rate</span></code>, the rate parameter.</p>
<p>Samples are nonnegative integers, with a pmf given by</p>
<div class="math">
<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow><mi mathvariant="normal">r</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">e</mi></mrow><mi>k</mi></msup><mfrac><msup><mi>e</mi><mrow><mo>−</mo><mrow><mi mathvariant="normal">r</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">e</mi></mrow></mrow></msup><mrow><mi>k</mi><mo stretchy="false">!</mo></mrow></mfrac></mrow><annotation encoding="application/x-tex">\mathrm{rate}^k \frac{e^{-\mathrm{rate}}}{k!}

</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.156556em;vertical-align:-0.686em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">r</span><span class="mord mathrm">a</span><span class="mord mathrm">t</span><span class="mord mathrm">e</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8991079999999999em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathdefault mtight" style="margin-right:0.03148em;">k</span></span></span></span></span></span></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.470556em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathdefault" style="margin-right:0.03148em;">k</span><span class="mclose">!</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathdefault">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7935559999999999em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight"><span class="mord mathrm mtight">r</span><span class="mord mathrm mtight">a</span><span class="mord mathrm mtight">t</span><span class="mord mathrm mtight">e</span></span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span>

</div><p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Poisson</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mi">4</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
<span class="go">tensor([ 3.])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>rate</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the rate parameter</p>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.poisson.Poisson.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'rate': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.poisson.Poisson.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.poisson.Poisson.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/poisson.html#Poisson.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.poisson.Poisson.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.poisson.Poisson.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/poisson.html#Poisson.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.poisson.Poisson.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.poisson.Poisson.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.poisson.Poisson.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.poisson.Poisson.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/poisson.html#Poisson.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.poisson.Poisson.sample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.poisson.Poisson.support">
<code class="sig-name descname">support</code><em class="property"> = IntegerGreaterThan(lower_bound=0)</em><a class="headerlink" href="#torch.distributions.poisson.Poisson.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.poisson.Poisson.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.poisson.Poisson.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="relaxedbernoulli">
<h2><span class="hidden-section">RelaxedBernoulli</span><a class="headerlink" href="#relaxedbernoulli" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.relaxed_bernoulli.RelaxedBernoulli">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.relaxed_bernoulli.</code><code class="sig-name descname">RelaxedBernoulli</code><span class="sig-paren">(</span><em class="sig-param">temperature</em>, <em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/relaxed_bernoulli.html#RelaxedBernoulli"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.transformed_distribution.TransformedDistribution</span></code></a></p>
<p>Creates a RelaxedBernoulli distribution, parametrized by
<a class="reference internal" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.temperature" title="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.temperature"><code class="xref py py-attr docutils literal notranslate"><span class="pre">temperature</span></code></a>, and either <a class="reference internal" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.probs" title="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> or <a class="reference internal" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.logits" title="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a>
(but not both). This is a relaxed version of the <cite>Bernoulli</cite> distribution,
so the values are in (0, 1), and has reparametrizable samples.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">RelaxedBernoulli</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">2.2</span><span class="p">]),</span>
<span class="go">                         torch.tensor([0.1, 0.2, 0.3, 0.99]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
<span class="go">tensor([ 0.2951,  0.3442,  0.8918,  0.9021])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>temperature</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – relaxation temperature</p></li>
<li><p><strong>probs</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the probability of sampling <cite>1</cite></p></li>
<li><p><strong>logits</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the log-odds of sampling <cite>1</cite></p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0)}</em><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/relaxed_bernoulli.html#RelaxedBernoulli.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.logits">
<em class="property">property </em><code class="sig-name descname">logits</code><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.probs">
<em class="property">property </em><code class="sig-name descname">probs</code><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.support">
<code class="sig-name descname">support</code><em class="property"> = Interval(lower_bound=0.0, upper_bound=1.0)</em><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_bernoulli.RelaxedBernoulli.temperature">
<em class="property">property </em><code class="sig-name descname">temperature</code><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli.temperature" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="logitrelaxedbernoulli">
<h2><span class="hidden-section">LogitRelaxedBernoulli</span><a class="headerlink" href="#logitrelaxedbernoulli" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.relaxed_bernoulli.</code><code class="sig-name descname">LogitRelaxedBernoulli</code><span class="sig-paren">(</span><em class="sig-param">temperature</em>, <em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/relaxed_bernoulli.html#LogitRelaxedBernoulli"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a LogitRelaxedBernoulli distribution parameterized by <a class="reference internal" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.probs" title="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a>
or <a class="reference internal" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.logits" title="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a> (but not both), which is the logit of a RelaxedBernoulli
distribution.</p>
<p>Samples are logits of values in (0, 1). See [1] for more details.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>temperature</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – relaxation temperature</p></li>
<li><p><strong>probs</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the probability of sampling <cite>1</cite></p></li>
<li><p><strong>logits</strong> (<em>Number</em><em>, </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the log-odds of sampling <cite>1</cite></p></li>
</ul>
</dd>
</dl>
<p>[1] The Concrete Distribution: A Continuous Relaxation of Discrete Random
Variables (Maddison et al, 2017)</p>
<p>[2] Categorical Reparametrization with Gumbel-Softmax
(Jang et al, 2017)</p>
<dl class="attribute">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0)}</em><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/relaxed_bernoulli.html#LogitRelaxedBernoulli.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/relaxed_bernoulli.html#LogitRelaxedBernoulli.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.logits">
<code class="sig-name descname">logits</code><a class="reference internal" href="_modules/torch/distributions/relaxed_bernoulli.html#LogitRelaxedBernoulli.logits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.param_shape">
<em class="property">property </em><code class="sig-name descname">param_shape</code><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.param_shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.probs">
<code class="sig-name descname">probs</code><a class="reference internal" href="_modules/torch/distributions/relaxed_bernoulli.html#LogitRelaxedBernoulli.probs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/relaxed_bernoulli.html#LogitRelaxedBernoulli.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="relaxedonehotcategorical">
<h2><span class="hidden-section">RelaxedOneHotCategorical</span><a class="headerlink" href="#relaxedonehotcategorical" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.relaxed_categorical.</code><code class="sig-name descname">RelaxedOneHotCategorical</code><span class="sig-paren">(</span><em class="sig-param">temperature</em>, <em class="sig-param">probs=None</em>, <em class="sig-param">logits=None</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/relaxed_categorical.html#RelaxedOneHotCategorical"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.transformed_distribution.TransformedDistribution</span></code></a></p>
<p>Creates a RelaxedOneHotCategorical distribution parametrized by
<a class="reference internal" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.temperature" title="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.temperature"><code class="xref py py-attr docutils literal notranslate"><span class="pre">temperature</span></code></a>, and either <a class="reference internal" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.probs" title="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.probs"><code class="xref py py-attr docutils literal notranslate"><span class="pre">probs</span></code></a> or <a class="reference internal" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.logits" title="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.logits"><code class="xref py py-attr docutils literal notranslate"><span class="pre">logits</span></code></a>.
This is a relaxed version of the <code class="xref py py-class docutils literal notranslate"><span class="pre">OneHotCategorical</span></code> distribution, so
its samples are on simplex, and are reparametrizable.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">RelaxedOneHotCategorical</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">2.2</span><span class="p">]),</span>
<span class="go">                                 torch.tensor([0.1, 0.2, 0.3, 0.4]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
<span class="go">tensor([ 0.1294,  0.2324,  0.3859,  0.2523])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>temperature</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – relaxation temperature</p></li>
<li><p><strong>probs</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – event probabilities</p></li>
<li><p><strong>logits</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – the log probability of each event.</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'logits': Real(), 'probs': Simplex()}</em><a class="headerlink" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/relaxed_categorical.html#RelaxedOneHotCategorical.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.logits">
<em class="property">property </em><code class="sig-name descname">logits</code><a class="headerlink" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.logits" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.probs">
<em class="property">property </em><code class="sig-name descname">probs</code><a class="headerlink" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.probs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.support">
<code class="sig-name descname">support</code><em class="property"> = Simplex()</em><a class="headerlink" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.temperature">
<em class="property">property </em><code class="sig-name descname">temperature</code><a class="headerlink" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical.temperature" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="studentt">
<h2><span class="hidden-section">StudentT</span><a class="headerlink" href="#studentt" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.studentT.StudentT">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.studentT.</code><code class="sig-name descname">StudentT</code><span class="sig-paren">(</span><em class="sig-param">df</em>, <em class="sig-param">loc=0.0</em>, <em class="sig-param">scale=1.0</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/studentT.html#StudentT"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.studentT.StudentT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Creates a Student’s t-distribution parameterized by degree of
freedom <code class="xref py py-attr docutils literal notranslate"><span class="pre">df</span></code>, mean <code class="xref py py-attr docutils literal notranslate"><span class="pre">loc</span></code> and scale <code class="xref py py-attr docutils literal notranslate"><span class="pre">scale</span></code>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">StudentT</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">2.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># Student&#39;s t-distributed with degrees of freedom=2</span>
<span class="go">tensor([ 0.1046])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>df</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – degrees of freedom</p></li>
<li><p><strong>loc</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – mean of the distribution</p></li>
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – scale of the distribution</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.studentT.StudentT.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'df': GreaterThan(lower_bound=0.0), 'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.studentT.StudentT.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.studentT.StudentT.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/studentT.html#StudentT.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.studentT.StudentT.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.studentT.StudentT.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/studentT.html#StudentT.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.studentT.StudentT.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.studentT.StudentT.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.studentT.StudentT.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.studentT.StudentT.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/studentT.html#StudentT.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.studentT.StudentT.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.studentT.StudentT.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.studentT.StudentT.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.studentT.StudentT.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/studentT.html#StudentT.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.studentT.StudentT.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.studentT.StudentT.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.studentT.StudentT.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.studentT.StudentT.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.studentT.StudentT.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="transformeddistribution">
<h2><span class="hidden-section">TransformedDistribution</span><a class="headerlink" href="#transformeddistribution" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transformed_distribution.</code><code class="sig-name descname">TransformedDistribution</code><span class="sig-paren">(</span><em class="sig-param">base_distribution</em>, <em class="sig-param">transforms</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transformed_distribution.html#TransformedDistribution"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Extension of the Distribution class, which applies a sequence of Transforms
to a base distribution.  Let f be the composition of transforms applied:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">X</span> <span class="o">~</span> <span class="n">BaseDistribution</span>
<span class="n">Y</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">X</span><span class="p">)</span> <span class="o">~</span> <span class="n">TransformedDistribution</span><span class="p">(</span><span class="n">BaseDistribution</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
<span class="n">log</span> <span class="n">p</span><span class="p">(</span><span class="n">Y</span><span class="p">)</span> <span class="o">=</span> <span class="n">log</span> <span class="n">p</span><span class="p">(</span><span class="n">X</span><span class="p">)</span> <span class="o">+</span> <span class="n">log</span> <span class="o">|</span><span class="n">det</span> <span class="p">(</span><span class="n">dX</span><span class="o">/</span><span class="n">dY</span><span class="p">)</span><span class="o">|</span>
</pre></div>
</div>
<p>Note that the <code class="docutils literal notranslate"><span class="pre">.event_shape</span></code> of a <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">TransformedDistribution</span></code></a> is the
maximum shape of its base distribution and its transforms, since transforms
can introduce correlations among events.</p>
<p>An example for the usage of <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">TransformedDistribution</span></code></a> would be:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># Building a Logistic Distribution</span>
<span class="c1"># X ~ Uniform(0, 1)</span>
<span class="c1"># f = a + b * logit(X)</span>
<span class="c1"># Y ~ f(X) ~ Logistic(a, b)</span>
<span class="n">base_distribution</span> <span class="o">=</span> <span class="n">Uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">transforms</span> <span class="o">=</span> <span class="p">[</span><span class="n">SigmoidTransform</span><span class="p">()</span><span class="o">.</span><span class="n">inv</span><span class="p">,</span> <span class="n">AffineTransform</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">a</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="n">b</span><span class="p">)]</span>
<span class="n">logistic</span> <span class="o">=</span> <span class="n">TransformedDistribution</span><span class="p">(</span><span class="n">base_distribution</span><span class="p">,</span> <span class="n">transforms</span><span class="p">)</span>
</pre></div>
</div>
<p>For more examples, please look at the implementations of
<a class="reference internal" href="#torch.distributions.gumbel.Gumbel" title="torch.distributions.gumbel.Gumbel"><code class="xref py py-class docutils literal notranslate"><span class="pre">Gumbel</span></code></a>,
<a class="reference internal" href="#torch.distributions.half_cauchy.HalfCauchy" title="torch.distributions.half_cauchy.HalfCauchy"><code class="xref py py-class docutils literal notranslate"><span class="pre">HalfCauchy</span></code></a>,
<a class="reference internal" href="#torch.distributions.half_normal.HalfNormal" title="torch.distributions.half_normal.HalfNormal"><code class="xref py py-class docutils literal notranslate"><span class="pre">HalfNormal</span></code></a>,
<a class="reference internal" href="#torch.distributions.log_normal.LogNormal" title="torch.distributions.log_normal.LogNormal"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogNormal</span></code></a>,
<a class="reference internal" href="#torch.distributions.pareto.Pareto" title="torch.distributions.pareto.Pareto"><code class="xref py py-class docutils literal notranslate"><span class="pre">Pareto</span></code></a>,
<a class="reference internal" href="#torch.distributions.weibull.Weibull" title="torch.distributions.weibull.Weibull"><code class="xref py py-class docutils literal notranslate"><span class="pre">Weibull</span></code></a>,
<a class="reference internal" href="#torch.distributions.relaxed_bernoulli.RelaxedBernoulli" title="torch.distributions.relaxed_bernoulli.RelaxedBernoulli"><code class="xref py py-class docutils literal notranslate"><span class="pre">RelaxedBernoulli</span></code></a> and
<a class="reference internal" href="#torch.distributions.relaxed_categorical.RelaxedOneHotCategorical" title="torch.distributions.relaxed_categorical.RelaxedOneHotCategorical"><code class="xref py py-class docutils literal notranslate"><span class="pre">RelaxedOneHotCategorical</span></code></a></p>
<dl class="attribute">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {}</em><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transformed_distribution.html#TransformedDistribution.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.cdf" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the cumulative distribution function by inverting the
transform(s) and computing the score of the base distribution.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transformed_distribution.html#TransformedDistribution.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.has_rsample">
<em class="property">property </em><code class="sig-name descname">has_rsample</code><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transformed_distribution.html#TransformedDistribution.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.icdf" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the inverse cumulative distribution function using
transform(s) and computing the score of the base distribution.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transformed_distribution.html#TransformedDistribution.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.log_prob" title="Permalink to this definition">¶</a></dt>
<dd><p>Scores the sample by inverting the transform(s) and computing the score
using the score of the base distribution and the log abs det jacobian.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transformed_distribution.html#TransformedDistribution.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.rsample" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates a sample_shape shaped reparameterized sample or sample_shape
shaped batch of reparameterized samples if the distribution parameters
are batched. Samples first from base distribution and applies
<cite>transform()</cite> for every transform in the list.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transformed_distribution.html#TransformedDistribution.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.sample" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates a sample_shape shaped sample or sample_shape shaped batch of
samples if the distribution parameters are batched. Samples first from
base distribution and applies <cite>transform()</cite> for every transform in the
list.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.transformed_distribution.TransformedDistribution.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.transformed_distribution.TransformedDistribution.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="uniform">
<h2><span class="hidden-section">Uniform</span><a class="headerlink" href="#uniform" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.uniform.Uniform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.uniform.</code><code class="sig-name descname">Uniform</code><span class="sig-paren">(</span><em class="sig-param">low</em>, <em class="sig-param">high</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/uniform.html#Uniform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.uniform.Uniform" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>Generates uniformly distributed random samples from the half-open interval
<code class="docutils literal notranslate"><span class="pre">[low,</span> <span class="pre">high)</span></code>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Uniform</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">0.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">5.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># uniformly distributed in the range [0.0, 5.0)</span>
<span class="go">tensor([ 2.3418])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>low</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – lower range (inclusive).</p></li>
<li><p><strong>high</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – upper range (exclusive).</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.uniform.Uniform.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'high': Dependent(), 'low': Dependent()}</em><a class="headerlink" href="#torch.distributions.uniform.Uniform.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.cdf">
<code class="sig-name descname">cdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/uniform.html#Uniform.cdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.uniform.Uniform.cdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/uniform.html#Uniform.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.uniform.Uniform.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/uniform.html#Uniform.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.uniform.Uniform.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.uniform.Uniform.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = True</em><a class="headerlink" href="#torch.distributions.uniform.Uniform.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.icdf">
<code class="sig-name descname">icdf</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/uniform.html#Uniform.icdf"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.uniform.Uniform.icdf" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/uniform.html#Uniform.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.uniform.Uniform.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.uniform.Uniform.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.rsample">
<code class="sig-name descname">rsample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/uniform.html#Uniform.rsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.uniform.Uniform.rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.stddev">
<em class="property">property </em><code class="sig-name descname">stddev</code><a class="headerlink" href="#torch.distributions.uniform.Uniform.stddev" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.support">
<em class="property">property </em><code class="sig-name descname">support</code><a class="headerlink" href="#torch.distributions.uniform.Uniform.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.uniform.Uniform.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.uniform.Uniform.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="vonmises">
<h2><span class="hidden-section">VonMises</span><a class="headerlink" href="#vonmises" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.von_mises.VonMises">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.von_mises.</code><code class="sig-name descname">VonMises</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">concentration</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/von_mises.html#VonMises"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.von_mises.VonMises" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.distribution.Distribution</span></code></a></p>
<p>A circular von Mises distribution.</p>
<p>This implementation uses polar coordinates. The <code class="docutils literal notranslate"><span class="pre">loc</span></code> and <code class="docutils literal notranslate"><span class="pre">value</span></code> args
can be any real number (to facilitate unconstrained optimization), but are
interpreted as angles modulo 2 pi.</p>
<dl>
<dt>Example::</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">dist</span><span class="o">.</span><span class="n">VonMises</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span> <span class="c1"># von Mises distributed with loc=1 and concentration=1</span>
<span class="go">tensor([1.9777])</span>
</pre></div>
</div>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>torch.Tensor</em></a>) – an angle in radians.</p></li>
<li><p><strong>concentration</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>torch.Tensor</em></a>) – concentration parameter</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.von_mises.VonMises.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'concentration': GreaterThan(lower_bound=0.0), 'loc': Real()}</em><a class="headerlink" href="#torch.distributions.von_mises.VonMises.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.von_mises.VonMises.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/von_mises.html#VonMises.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.von_mises.VonMises.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.von_mises.VonMises.has_rsample">
<code class="sig-name descname">has_rsample</code><em class="property"> = False</em><a class="headerlink" href="#torch.distributions.von_mises.VonMises.has_rsample" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.von_mises.VonMises.log_prob">
<code class="sig-name descname">log_prob</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/von_mises.html#VonMises.log_prob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.von_mises.VonMises.log_prob" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.von_mises.VonMises.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.von_mises.VonMises.mean" title="Permalink to this definition">¶</a></dt>
<dd><p>The provided mean is the circular one.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.von_mises.VonMises.sample">
<code class="sig-name descname">sample</code><span class="sig-paren">(</span><em class="sig-param">sample_shape=torch.Size([])</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/von_mises.html#VonMises.sample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.von_mises.VonMises.sample" title="Permalink to this definition">¶</a></dt>
<dd><p>The sampling algorithm for the von Mises distribution is based on the following paper:
Best, D. J., and Nicholas I. Fisher.
“Efficient simulation of the von Mises distribution.” Applied Statistics (1979): 152-157.</p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.von_mises.VonMises.support">
<code class="sig-name descname">support</code><em class="property"> = Real()</em><a class="headerlink" href="#torch.distributions.von_mises.VonMises.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.von_mises.VonMises.variance">
<code class="sig-name descname">variance</code><a class="reference internal" href="_modules/torch/distributions/von_mises.html#VonMises.variance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.von_mises.VonMises.variance" title="Permalink to this definition">¶</a></dt>
<dd><p>The provided variance is the circular one.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="weibull">
<h2><span class="hidden-section">Weibull</span><a class="headerlink" href="#weibull" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.weibull.Weibull">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.weibull.</code><code class="sig-name descname">Weibull</code><span class="sig-paren">(</span><em class="sig-param">scale</em>, <em class="sig-param">concentration</em>, <em class="sig-param">validate_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/weibull.html#Weibull"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.weibull.Weibull" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#torch.distributions.transformed_distribution.TransformedDistribution" title="torch.distributions.transformed_distribution.TransformedDistribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.transformed_distribution.TransformedDistribution</span></code></a></p>
<p>Samples from a two-parameter Weibull distribution.</p>
<p class="rubric">Example</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">Weibull</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]),</span> <span class="n">torch</span><span class="o">.</span><span class="n">tensor</span><span class="p">([</span><span class="mf">1.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>  <span class="c1"># sample from a Weibull distribution with scale=1, concentration=1</span>
<span class="go">tensor([ 0.4784])</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Scale parameter of distribution (lambda).</p></li>
<li><p><strong>concentration</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Concentration parameter of distribution (k/shape).</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="torch.distributions.weibull.Weibull.arg_constraints">
<code class="sig-name descname">arg_constraints</code><em class="property"> = {'concentration': GreaterThan(lower_bound=0.0), 'scale': GreaterThan(lower_bound=0.0)}</em><a class="headerlink" href="#torch.distributions.weibull.Weibull.arg_constraints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.weibull.Weibull.entropy">
<code class="sig-name descname">entropy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/weibull.html#Weibull.entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.weibull.Weibull.entropy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.weibull.Weibull.expand">
<code class="sig-name descname">expand</code><span class="sig-paren">(</span><em class="sig-param">batch_shape</em>, <em class="sig-param">_instance=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/weibull.html#Weibull.expand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.weibull.Weibull.expand" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.weibull.Weibull.mean">
<em class="property">property </em><code class="sig-name descname">mean</code><a class="headerlink" href="#torch.distributions.weibull.Weibull.mean" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="torch.distributions.weibull.Weibull.support">
<code class="sig-name descname">support</code><em class="property"> = GreaterThan(lower_bound=0.0)</em><a class="headerlink" href="#torch.distributions.weibull.Weibull.support" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="torch.distributions.weibull.Weibull.variance">
<em class="property">property </em><code class="sig-name descname">variance</code><a class="headerlink" href="#torch.distributions.weibull.Weibull.variance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="module-torch.distributions.kl">
<span id="kl-divergence"></span><h2><cite>KL Divergence</cite><a class="headerlink" href="#module-torch.distributions.kl" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="torch.distributions.kl.kl_divergence">
<code class="sig-prename descclassname">torch.distributions.kl.</code><code class="sig-name descname">kl_divergence</code><span class="sig-paren">(</span><em class="sig-param">p</em>, <em class="sig-param">q</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/kl.html#kl_divergence"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.kl.kl_divergence" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute Kullback-Leibler divergence <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>K</mi><mi>L</mi><mo stretchy="false">(</mo><mi>p</mi><mi mathvariant="normal">∥</mi><mi>q</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">KL(p \| q)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.07153em;">K</span><span class="mord mathdefault">L</span><span class="mopen">(</span><span class="mord mathdefault">p</span><span class="mord">∥</span><span class="mord mathdefault" style="margin-right:0.03588em;">q</span><span class="mclose">)</span></span></span></span>

</span> between two distributions.</p>
<div class="math">
<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>K</mi><mi>L</mi><mo stretchy="false">(</mo><mi>p</mi><mi mathvariant="normal">∥</mi><mi>q</mi><mo stretchy="false">)</mo><mo>=</mo><mo>∫</mo><mi>p</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mi>log</mi><mo>⁡</mo><mfrac><mrow><mi>p</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mfrac><mtext> </mtext><mi>d</mi><mi>x</mi></mrow><annotation encoding="application/x-tex">KL(p \| q) = \int p(x) \log\frac {p(x)} {q(x)} \,dx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.07153em;">K</span><span class="mord mathdefault">L</span><span class="mopen">(</span><span class="mord mathdefault">p</span><span class="mord">∥</span><span class="mord mathdefault" style="margin-right:0.03588em;">q</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:2.363em;vertical-align:-0.936em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011249999999999316em;">∫</span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathdefault">p</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathdefault" style="margin-right:0.03588em;">q</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathdefault">p</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathdefault">d</span><span class="mord mathdefault">x</span></span></span></span></span>

</div><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>p</strong> (<a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><em>Distribution</em></a>) – A <code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code> object.</p></li>
<li><p><strong>q</strong> (<a class="reference internal" href="#torch.distributions.distribution.Distribution" title="torch.distributions.distribution.Distribution"><em>Distribution</em></a>) – A <code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code> object.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A batch of KL divergences of shape <cite>batch_shape</cite>.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor">Tensor</a></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#NotImplementedError" title="(in Python v3.8)"><strong>NotImplementedError</strong></a> – If the distribution types have not been registered via
    <a class="reference internal" href="#torch.distributions.kl.register_kl" title="torch.distributions.kl.register_kl"><code class="xref py py-meth docutils literal notranslate"><span class="pre">register_kl()</span></code></a>.</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="torch.distributions.kl.register_kl">
<code class="sig-prename descclassname">torch.distributions.kl.</code><code class="sig-name descname">register_kl</code><span class="sig-paren">(</span><em class="sig-param">type_p</em>, <em class="sig-param">type_q</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/kl.html#register_kl"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.kl.register_kl" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator to register a pairwise function with <a class="reference internal" href="#torch.distributions.kl.kl_divergence" title="torch.distributions.kl.kl_divergence"><code class="xref py py-meth docutils literal notranslate"><span class="pre">kl_divergence()</span></code></a>.
Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@register_kl</span><span class="p">(</span><span class="n">Normal</span><span class="p">,</span> <span class="n">Normal</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">kl_normal_normal</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">q</span><span class="p">):</span>
    <span class="c1"># insert implementation here</span>
</pre></div>
</div>
<p>Lookup returns the most specific (type,type) match ordered by subclass. If
the match is ambiguous, a <cite>RuntimeWarning</cite> is raised. For example to
resolve the ambiguous situation:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@register_kl</span><span class="p">(</span><span class="n">BaseP</span><span class="p">,</span> <span class="n">DerivedQ</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">kl_version1</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">q</span><span class="p">):</span> <span class="o">...</span>
<span class="nd">@register_kl</span><span class="p">(</span><span class="n">DerivedP</span><span class="p">,</span> <span class="n">BaseQ</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">kl_version2</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">q</span><span class="p">):</span> <span class="o">...</span>
</pre></div>
</div>
<p>you should register a third most-specific implementation, e.g.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">register_kl</span><span class="p">(</span><span class="n">DerivedP</span><span class="p">,</span> <span class="n">DerivedQ</span><span class="p">)(</span><span class="n">kl_version1</span><span class="p">)</span>  <span class="c1"># Break the tie.</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>type_p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#type" title="(in Python v3.8)"><em>type</em></a>) – A subclass of <code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code>.</p></li>
<li><p><strong>type_q</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#type" title="(in Python v3.8)"><em>type</em></a>) – A subclass of <code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</div>
<div class="section" id="module-torch.distributions.transforms">
<span id="transforms"></span><h2><cite>Transforms</cite><a class="headerlink" href="#module-torch.distributions.transforms" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torch.distributions.transforms.Transform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">Transform</code><span class="sig-paren">(</span><em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#Transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.Transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Abstract class for invertable transformations with computable log
det jacobians. They are primarily used in
<code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.TransformedDistribution</span></code>.</p>
<p>Caching is useful for transforms whose inverses are either expensive or
numerically unstable. Note that care must be taken with memoized values
since the autograd graph may be reversed. For example while the following
works with or without caching:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">y</span> <span class="o">=</span> <span class="n">t</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">t</span><span class="o">.</span><span class="n">log_abs_det_jacobian</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">backward</span><span class="p">()</span>  <span class="c1"># x will receive gradients.</span>
</pre></div>
</div>
<p>However the following will error when caching due to dependency reversal:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">y</span> <span class="o">=</span> <span class="n">t</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">z</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">inv</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="n">grad</span><span class="p">(</span><span class="n">z</span><span class="o">.</span><span class="n">sum</span><span class="p">(),</span> <span class="p">[</span><span class="n">y</span><span class="p">])</span>  <span class="c1"># error because z is x</span>
</pre></div>
</div>
<p>Derived classes should implement one or both of <code class="xref py py-meth docutils literal notranslate"><span class="pre">_call()</span></code> or
<code class="xref py py-meth docutils literal notranslate"><span class="pre">_inverse()</span></code>. Derived classes that set <cite>bijective=True</cite> should also
implement <a class="reference internal" href="#torch.distributions.transforms.Transform.log_abs_det_jacobian" title="torch.distributions.transforms.Transform.log_abs_det_jacobian"><code class="xref py py-meth docutils literal notranslate"><span class="pre">log_abs_det_jacobian()</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>cache_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Size of cache. If zero, no caching is done. If one,
the latest single value is cached. Only 0 and 1 are supported.</p>
</dd>
<dt class="field-even">Variables</dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>~Transform.domain</strong> (<a class="reference internal" href="#torch.distributions.constraints.Constraint" title="torch.distributions.constraints.Constraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code></a>) – The constraint representing valid inputs to this transform.</p></li>
<li><p><strong>~Transform.codomain</strong> (<a class="reference internal" href="#torch.distributions.constraints.Constraint" title="torch.distributions.constraints.Constraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code></a>) – The constraint representing valid outputs to this transform
which are inputs to the inverse transform.</p></li>
<li><p><strong>~Transform.bijective</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a>) – Whether this transform is bijective. A transform
<code class="docutils literal notranslate"><span class="pre">t</span></code> is bijective iff <code class="docutils literal notranslate"><span class="pre">t.inv(t(x))</span> <span class="pre">==</span> <span class="pre">x</span></code> and
<code class="docutils literal notranslate"><span class="pre">t(t.inv(y))</span> <span class="pre">==</span> <span class="pre">y</span></code> for every <code class="docutils literal notranslate"><span class="pre">x</span></code> in the domain and <code class="docutils literal notranslate"><span class="pre">y</span></code> in
the codomain. Transforms that are not bijective should at least
maintain the weaker pseudoinverse properties
<code class="docutils literal notranslate"><span class="pre">t(t.inv(t(x))</span> <span class="pre">==</span> <span class="pre">t(x)</span></code> and <code class="docutils literal notranslate"><span class="pre">t.inv(t(t.inv(y)))</span> <span class="pre">==</span> <span class="pre">t.inv(y)</span></code>.</p></li>
<li><p><strong>~Transform.sign</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – For bijective univariate transforms, this
should be +1 or -1 depending on whether transform is monotone
increasing or decreasing.</p></li>
<li><p><strong>~Transform.event_dim</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Number of dimensions that are correlated together in
the transform <code class="docutils literal notranslate"><span class="pre">event_shape</span></code>. This should be 0 for pointwise
transforms, 1 for transforms that act jointly on vectors, 2 for
transforms that act jointly on matrices, etc.</p></li>
</ul>
</dd>
</dl>
<dl class="method">
<dt id="torch.distributions.transforms.Transform.inv">
<em class="property">property </em><code class="sig-name descname">inv</code><a class="headerlink" href="#torch.distributions.transforms.Transform.inv" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the inverse <a class="reference internal" href="#torch.distributions.transforms.Transform" title="torch.distributions.transforms.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a> of this transform.
This should satisfy <code class="docutils literal notranslate"><span class="pre">t.inv.inv</span> <span class="pre">is</span> <span class="pre">t</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.transforms.Transform.sign">
<em class="property">property </em><code class="sig-name descname">sign</code><a class="headerlink" href="#torch.distributions.transforms.Transform.sign" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the sign of the determinant of the Jacobian, if applicable.
In general this only makes sense for bijective transforms.</p>
</dd></dl>

<dl class="method">
<dt id="torch.distributions.transforms.Transform.log_abs_det_jacobian">
<code class="sig-name descname">log_abs_det_jacobian</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#Transform.log_abs_det_jacobian"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.Transform.log_abs_det_jacobian" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the log det jacobian <cite>log |dy/dx|</cite> given input and output.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.ComposeTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">ComposeTransform</code><span class="sig-paren">(</span><em class="sig-param">parts</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#ComposeTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.ComposeTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Composes multiple transforms in a chain.
The transforms being composed are responsible for caching.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>parts</strong> (list of <a class="reference internal" href="#torch.distributions.transforms.Transform" title="torch.distributions.transforms.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a>) – A list of transforms to compose.</p>
</dd>
</dl>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.ExpTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">ExpTransform</code><span class="sig-paren">(</span><em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#ExpTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.ExpTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform via the mapping <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi><mo>=</mo><mi>exp</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">y = \exp(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.19444em;"></span><span class="mord mathdefault" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">exp</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span></span>

</span>.</p>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.PowerTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">PowerTransform</code><span class="sig-paren">(</span><em class="sig-param">exponent</em>, <em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#PowerTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.PowerTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform via the mapping <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi><mo>=</mo><msup><mi>x</mi><mtext>exponent</mtext></msup></mrow><annotation encoding="application/x-tex">y = x^{\text{exponent}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.19444em;"></span><span class="mord mathdefault" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:0.7935559999999999em;vertical-align:0em;"></span><span class="mord"><span class="mord mathdefault">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7935559999999999em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">exponent</span></span></span></span></span></span></span></span></span></span></span></span></span>

</span>.</p>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.SigmoidTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">SigmoidTransform</code><span class="sig-paren">(</span><em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#SigmoidTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.SigmoidTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform via the mapping <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi><mo>=</mo><mfrac><mn>1</mn><mrow><mn>1</mn><mo>+</mo><mi>exp</mi><mo>⁡</mo><mo stretchy="false">(</mo><mo>−</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mfrac></mrow><annotation encoding="application/x-tex">y = \frac{1}{1 + \exp(-x)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.19444em;"></span><span class="mord mathdefault" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:1.365108em;vertical-align:-0.52em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.845108em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mbin mtight">+</span><span class="mop mtight"><span class="mtight">e</span><span class="mtight">x</span><span class="mtight">p</span></span><span class="mopen mtight">(</span><span class="mord mtight">−</span><span class="mord mathdefault mtight">x</span><span class="mclose mtight">)</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.52em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>

</span> and <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo>=</mo><mtext>logit</mtext><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x = \text{logit}(y)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.43056em;vertical-align:0em;"></span><span class="mord mathdefault">x</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">logit</span></span><span class="mopen">(</span><span class="mord mathdefault" style="margin-right:0.03588em;">y</span><span class="mclose">)</span></span></span></span>

</span>.</p>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.TanhTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">TanhTransform</code><span class="sig-paren">(</span><em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#TanhTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.TanhTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform via the mapping <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi><mo>=</mo><mi>tanh</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">y = \tanh(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.19444em;"></span><span class="mord mathdefault" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">tanh</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span></span>

</span>.</p>
<p>It is equivalent to
<code class="docutils literal notranslate"><span class="pre">`</span>
<span class="pre">ComposeTransform([AffineTransform(0.,</span> <span class="pre">2.),</span> <span class="pre">SigmoidTransform(),</span> <span class="pre">AffineTransform(-1.,</span> <span class="pre">2.)])</span>
<span class="pre">`</span></code>
However this might not be numerically stable, thus it is recommended to use <cite>TanhTransform</cite>
instead.</p>
<p>Note that one should use <cite>cache_size=1</cite> when it comes to <cite>NaN/Inf</cite> values.</p>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.AbsTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">AbsTransform</code><span class="sig-paren">(</span><em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#AbsTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.AbsTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform via the mapping <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi><mo>=</mo><mi mathvariant="normal">∣</mi><mi>x</mi><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">y = |x|</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.19444em;"></span><span class="mord mathdefault" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span><span class="mord mathdefault">x</span><span class="mord">∣</span></span></span></span>

</span>.</p>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.AffineTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">AffineTransform</code><span class="sig-paren">(</span><em class="sig-param">loc</em>, <em class="sig-param">scale</em>, <em class="sig-param">event_dim=0</em>, <em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#AffineTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.AffineTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform via the pointwise affine mapping <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi><mo>=</mo><mtext>loc</mtext><mo>+</mo><mtext>scale</mtext><mo>×</mo><mi>x</mi></mrow><annotation encoding="application/x-tex">y = \text{loc} + \text{scale} \times x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.19444em;"></span><span class="mord mathdefault" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:0.77777em;vertical-align:-0.08333em;"></span><span class="mord text"><span class="mord">loc</span></span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:0.77777em;vertical-align:-0.08333em;"></span><span class="mord text"><span class="mord">scale</span></span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:0.43056em;vertical-align:0em;"></span><span class="mord mathdefault">x</span></span></span></span>

</span>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loc</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – Location parameter.</p></li>
<li><p><strong>scale</strong> (<a class="reference internal" href="tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – Scale parameter.</p></li>
<li><p><strong>event_dim</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Optional size of <cite>event_shape</cite>. This should be zero
for univariate random variables, 1 for distributions over vectors,
2 for distributions over matrices, etc.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.SoftmaxTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">SoftmaxTransform</code><span class="sig-paren">(</span><em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#SoftmaxTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.SoftmaxTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform from unconstrained space to the simplex via <span class="math"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi><mo>=</mo><mi>exp</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">y = \exp(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.19444em;"></span><span class="mord mathdefault" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">exp</span><span class="mopen">(</span><span class="mord mathdefault">x</span><span class="mclose">)</span></span></span></span>

</span> then
normalizing.</p>
<p>This is not bijective and cannot be used for HMC. However this acts mostly
coordinate-wise (except for the final normalization), and thus is
appropriate for coordinate-wise optimization algorithms.</p>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.StickBreakingTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">StickBreakingTransform</code><span class="sig-paren">(</span><em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#StickBreakingTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.StickBreakingTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform from unconstrained space to the simplex of one additional
dimension via a stick-breaking process.</p>
<p>This transform arises as an iterated sigmoid transform in a stick-breaking
construction of the <cite>Dirichlet</cite> distribution: the first logit is
transformed via sigmoid to the first probability and the probability of
everything else, and then the process recurses.</p>
<p>This is bijective and appropriate for use in HMC; however it mixes
coordinates together and is less appropriate for optimization.</p>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.LowerCholeskyTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">LowerCholeskyTransform</code><span class="sig-paren">(</span><em class="sig-param">cache_size=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#LowerCholeskyTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.LowerCholeskyTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform from unconstrained matrices to lower-triangular matrices with
nonnegative diagonal entries.</p>
<p>This is useful for parameterizing positive definite matrices in terms of
their Cholesky factorization.</p>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.CatTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">CatTransform</code><span class="sig-paren">(</span><em class="sig-param">tseq</em>, <em class="sig-param">dim=0</em>, <em class="sig-param">lengths=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#CatTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.CatTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform functor that applies a sequence of transforms <cite>tseq</cite>
component-wise to each submatrix at <cite>dim</cite>, of length <cite>lengths[dim]</cite>,
in a way compatible with <a class="reference internal" href="torch.html#torch.cat" title="torch.cat"><code class="xref py py-func docutils literal notranslate"><span class="pre">torch.cat()</span></code></a>.</p>
<dl class="simple">
<dt>Example::</dt><dd><p>x0 = torch.cat([torch.range(1, 10), torch.range(1, 10)], dim=0)
x = torch.cat([x0, x0], dim=0)
t0 = CatTransform([ExpTransform(), identity_transform], dim=0, lengths=[10, 10])
t = CatTransform([t0, t0], dim=0, lengths=[20, 20])
y = t(x)</p>
</dd>
</dl>
</dd></dl>

<dl class="class">
<dt id="torch.distributions.transforms.StackTransform">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.transforms.</code><code class="sig-name descname">StackTransform</code><span class="sig-paren">(</span><em class="sig-param">tseq</em>, <em class="sig-param">dim=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/transforms.html#StackTransform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.transforms.StackTransform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform functor that applies a sequence of transforms <cite>tseq</cite>
component-wise to each submatrix at <cite>dim</cite>
in a way compatible with <a class="reference internal" href="torch.html#torch.stack" title="torch.stack"><code class="xref py py-func docutils literal notranslate"><span class="pre">torch.stack()</span></code></a>.</p>
<dl class="simple">
<dt>Example::</dt><dd><p>x = torch.stack([torch.range(1, 10), torch.range(1, 10)], dim=1)
t = StackTransform([ExpTransform(), identity_transform], dim=1)
y = t(x)</p>
</dd>
</dl>
</dd></dl>

</div>
<div class="section" id="module-torch.distributions.constraints">
<span id="constraints"></span><h2><cite>Constraints</cite><a class="headerlink" href="#module-torch.distributions.constraints" title="Permalink to this headline">¶</a></h2>
<p>The following constraints are implemented:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.boolean</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.cat</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.dependent</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.greater_than(lower_bound)</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.integer_interval(lower_bound,</span> <span class="pre">upper_bound)</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.interval(lower_bound,</span> <span class="pre">upper_bound)</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.lower_cholesky</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.lower_triangular</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.nonnegative_integer</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.positive</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.positive_definite</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.positive_integer</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.real</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.real_vector</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.simplex</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.stack</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">constraints.unit_interval</span></code></p></li>
</ul>
<dl class="class">
<dt id="torch.distributions.constraints.Constraint">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">Constraint</code><a class="reference internal" href="_modules/torch/distributions/constraints.html#Constraint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.constraints.Constraint" title="Permalink to this definition">¶</a></dt>
<dd><p>Abstract base class for constraints.</p>
<p>A constraint object represents a region over which a variable is valid,
e.g. within which a variable can be optimized.</p>
<dl class="method">
<dt id="torch.distributions.constraints.Constraint.check">
<code class="sig-name descname">check</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/constraints.html#Constraint.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.constraints.Constraint.check" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a byte tensor of <cite>sample_shape + batch_shape</cite> indicating
whether each event in value satisfies this constraint.</p>
</dd></dl>

</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.dependent_property">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">dependent_property</code><a class="headerlink" href="#torch.distributions.constraints.dependent_property" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._DependentProperty</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.integer_interval">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">integer_interval</code><a class="headerlink" href="#torch.distributions.constraints.integer_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._IntegerInterval</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.greater_than">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">greater_than</code><a class="headerlink" href="#torch.distributions.constraints.greater_than" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._GreaterThan</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.greater_than_eq">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">greater_than_eq</code><a class="headerlink" href="#torch.distributions.constraints.greater_than_eq" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._GreaterThanEq</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.less_than">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">less_than</code><a class="headerlink" href="#torch.distributions.constraints.less_than" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._LessThan</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.interval">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">interval</code><a class="headerlink" href="#torch.distributions.constraints.interval" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._Interval</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.half_open_interval">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">half_open_interval</code><a class="headerlink" href="#torch.distributions.constraints.half_open_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._HalfOpenInterval</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.cat">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">cat</code><a class="headerlink" href="#torch.distributions.constraints.cat" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._Cat</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="torch.distributions.constraints.stack">
<code class="sig-prename descclassname">torch.distributions.constraints.</code><code class="sig-name descname">stack</code><a class="headerlink" href="#torch.distributions.constraints.stack" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.distributions.constraints._Stack</span></code></p>
</dd></dl>

</div>
<div class="section" id="module-torch.distributions.constraint_registry">
<span id="constraint-registry"></span><h2><cite>Constraint Registry</cite><a class="headerlink" href="#module-torch.distributions.constraint_registry" title="Permalink to this headline">¶</a></h2>
<p>PyTorch provides two global <a class="reference internal" href="#torch.distributions.constraint_registry.ConstraintRegistry" title="torch.distributions.constraint_registry.ConstraintRegistry"><code class="xref py py-class docutils literal notranslate"><span class="pre">ConstraintRegistry</span></code></a> objects that link
<a class="reference internal" href="#torch.distributions.constraints.Constraint" title="torch.distributions.constraints.Constraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code></a> objects to
<a class="reference internal" href="#torch.distributions.transforms.Transform" title="torch.distributions.transforms.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a> objects. These objects both
input constraints and return transforms, but they have different guarantees on
bijectivity.</p>
<ol class="arabic simple">
<li><p><code class="docutils literal notranslate"><span class="pre">biject_to(constraint)</span></code> looks up a bijective
<a class="reference internal" href="#torch.distributions.transforms.Transform" title="torch.distributions.transforms.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a> from <code class="docutils literal notranslate"><span class="pre">constraints.real</span></code>
to the given <code class="docutils literal notranslate"><span class="pre">constraint</span></code>. The returned transform is guaranteed to have
<code class="docutils literal notranslate"><span class="pre">.bijective</span> <span class="pre">=</span> <span class="pre">True</span></code> and should implement <code class="docutils literal notranslate"><span class="pre">.log_abs_det_jacobian()</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">transform_to(constraint)</span></code> looks up a not-necessarily bijective
<a class="reference internal" href="#torch.distributions.transforms.Transform" title="torch.distributions.transforms.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a> from <code class="docutils literal notranslate"><span class="pre">constraints.real</span></code>
to the given <code class="docutils literal notranslate"><span class="pre">constraint</span></code>. The returned transform is not guaranteed to
implement <code class="docutils literal notranslate"><span class="pre">.log_abs_det_jacobian()</span></code>.</p></li>
</ol>
<p>The <code class="docutils literal notranslate"><span class="pre">transform_to()</span></code> registry is useful for performing unconstrained
optimization on constrained parameters of probability distributions, which are
indicated by each distribution’s <code class="docutils literal notranslate"><span class="pre">.arg_constraints</span></code> dict. These transforms often
overparameterize a space in order to avoid rotation; they are thus more
suitable for coordinate-wise optimization algorithms like Adam:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">loc</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="n">requires_grad</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">unconstrained</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="n">requires_grad</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">scale</span> <span class="o">=</span> <span class="n">transform_to</span><span class="p">(</span><span class="n">Normal</span><span class="o">.</span><span class="n">arg_constraints</span><span class="p">[</span><span class="s1">&#39;scale&#39;</span><span class="p">])(</span><span class="n">unconstrained</span><span class="p">)</span>
<span class="n">loss</span> <span class="o">=</span> <span class="o">-</span><span class="n">Normal</span><span class="p">(</span><span class="n">loc</span><span class="p">,</span> <span class="n">scale</span><span class="p">)</span><span class="o">.</span><span class="n">log_prob</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">biject_to()</span></code> registry is useful for Hamiltonian Monte Carlo, where
samples from a probability distribution with constrained <code class="docutils literal notranslate"><span class="pre">.support</span></code> are
propagated in an unconstrained space, and algorithms are typically rotation
invariant.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">dist</span> <span class="o">=</span> <span class="n">Exponential</span><span class="p">(</span><span class="n">rate</span><span class="p">)</span>
<span class="n">unconstrained</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="n">requires_grad</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">sample</span> <span class="o">=</span> <span class="n">biject_to</span><span class="p">(</span><span class="n">dist</span><span class="o">.</span><span class="n">support</span><span class="p">)(</span><span class="n">unconstrained</span><span class="p">)</span>
<span class="n">potential_energy</span> <span class="o">=</span> <span class="o">-</span><span class="n">dist</span><span class="o">.</span><span class="n">log_prob</span><span class="p">(</span><span class="n">sample</span><span class="p">)</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>An example where <code class="docutils literal notranslate"><span class="pre">transform_to</span></code> and <code class="docutils literal notranslate"><span class="pre">biject_to</span></code> differ is
<code class="docutils literal notranslate"><span class="pre">constraints.simplex</span></code>: <code class="docutils literal notranslate"><span class="pre">transform_to(constraints.simplex)</span></code> returns a
<a class="reference internal" href="#torch.distributions.transforms.SoftmaxTransform" title="torch.distributions.transforms.SoftmaxTransform"><code class="xref py py-class docutils literal notranslate"><span class="pre">SoftmaxTransform</span></code></a> that simply
exponentiates and normalizes its inputs; this is a cheap and mostly
coordinate-wise operation appropriate for algorithms like SVI. In
contrast, <code class="docutils literal notranslate"><span class="pre">biject_to(constraints.simplex)</span></code> returns a
<a class="reference internal" href="#torch.distributions.transforms.StickBreakingTransform" title="torch.distributions.transforms.StickBreakingTransform"><code class="xref py py-class docutils literal notranslate"><span class="pre">StickBreakingTransform</span></code></a> that
bijects its input down to a one-fewer-dimensional space; this a more
expensive less numerically stable transform but is needed for algorithms
like HMC.</p>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">biject_to</span></code> and <code class="docutils literal notranslate"><span class="pre">transform_to</span></code> objects can be extended by user-defined
constraints and transforms using their <code class="docutils literal notranslate"><span class="pre">.register()</span></code> method either as a
function on singleton constraints:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">transform_to</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">my_constraint</span><span class="p">,</span> <span class="n">my_transform</span><span class="p">)</span>
</pre></div>
</div>
<p>or as a decorator on parameterized constraints:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@transform_to</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">MyConstraintClass</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">my_factory</span><span class="p">(</span><span class="n">constraint</span><span class="p">):</span>
    <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">constraint</span><span class="p">,</span> <span class="n">MyConstraintClass</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">MyTransform</span><span class="p">(</span><span class="n">constraint</span><span class="o">.</span><span class="n">param1</span><span class="p">,</span> <span class="n">constraint</span><span class="o">.</span><span class="n">param2</span><span class="p">)</span>
</pre></div>
</div>
<p>You can create your own registry by creating a new <a class="reference internal" href="#torch.distributions.constraint_registry.ConstraintRegistry" title="torch.distributions.constraint_registry.ConstraintRegistry"><code class="xref py py-class docutils literal notranslate"><span class="pre">ConstraintRegistry</span></code></a>
object.</p>
<dl class="class">
<dt id="torch.distributions.constraint_registry.ConstraintRegistry">
<em class="property">class </em><code class="sig-prename descclassname">torch.distributions.constraint_registry.</code><code class="sig-name descname">ConstraintRegistry</code><a class="reference internal" href="_modules/torch/distributions/constraint_registry.html#ConstraintRegistry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.constraint_registry.ConstraintRegistry" title="Permalink to this definition">¶</a></dt>
<dd><p>Registry to link constraints to transforms.</p>
<dl class="method">
<dt id="torch.distributions.constraint_registry.ConstraintRegistry.register">
<code class="sig-name descname">register</code><span class="sig-paren">(</span><em class="sig-param">constraint</em>, <em class="sig-param">factory=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torch/distributions/constraint_registry.html#ConstraintRegistry.register"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torch.distributions.constraint_registry.ConstraintRegistry.register" title="Permalink to this definition">¶</a></dt>
<dd><p>Registers a <a class="reference internal" href="#torch.distributions.constraints.Constraint" title="torch.distributions.constraints.Constraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code></a>
subclass in this registry. Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@my_registry</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">MyConstraintClass</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">construct_transform</span><span class="p">(</span><span class="n">constraint</span><span class="p">):</span>
    <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">constraint</span><span class="p">,</span> <span class="n">MyConstraint</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">MyTransform</span><span class="p">(</span><span class="n">constraint</span><span class="o">.</span><span class="n">arg_constraints</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>constraint</strong> (subclass of <a class="reference internal" href="#torch.distributions.constraints.Constraint" title="torch.distributions.constraints.Constraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code></a>) – A subclass of <a class="reference internal" href="#torch.distributions.constraints.Constraint" title="torch.distributions.constraints.Constraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code></a>, or
a singleton object of the desired class.</p></li>
<li><p><strong>factory</strong> (<em>callable</em>) – A callable that inputs a constraint object and returns
a  <a class="reference internal" href="#torch.distributions.transforms.Transform" title="torch.distributions.transforms.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a> object.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

</div>
</div>


             </article>
             
            </div>
            <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="hub.html" class="btn btn-neutral float-right" title="torch.hub" accesskey="n" rel="next">Next <img src="_static/images/chevron-right-orange.svg" class="next-page"></a>
      
      
        <a href="distributed.html" class="btn btn-neutral" title="Distributed communication package - torch.distributed" accesskey="p" rel="prev"><img src="_static/images/chevron-right-orange.svg" class="previous-page"> Previous</a>
      
    </div>
  

  

    <hr>

  

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, Torch Contributors.

    </p>
  </div>
    
      <div>
        Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
      </div>
     

</footer>

          </div>
        </div>

        <div class="pytorch-content-right" id="pytorch-content-right">
          <div class="pytorch-right-menu" id="pytorch-right-menu">
            <div class="pytorch-side-scroll" id="pytorch-side-scroll-right">
              <ul>
<li><a class="reference internal" href="#">Probability distributions - torch.distributions</a><ul>
<li><a class="reference internal" href="#score-function">Score function</a></li>
<li><a class="reference internal" href="#pathwise-derivative">Pathwise derivative</a></li>
<li><a class="reference internal" href="#distribution"><span class="hidden-section">Distribution</span></a></li>
<li><a class="reference internal" href="#exponentialfamily"><span class="hidden-section">ExponentialFamily</span></a></li>
<li><a class="reference internal" href="#bernoulli"><span class="hidden-section">Bernoulli</span></a></li>
<li><a class="reference internal" href="#beta"><span class="hidden-section">Beta</span></a></li>
<li><a class="reference internal" href="#binomial"><span class="hidden-section">Binomial</span></a></li>
<li><a class="reference internal" href="#categorical"><span class="hidden-section">Categorical</span></a></li>
<li><a class="reference internal" href="#cauchy"><span class="hidden-section">Cauchy</span></a></li>
<li><a class="reference internal" href="#chi2"><span class="hidden-section">Chi2</span></a></li>
<li><a class="reference internal" href="#continuousbernoulli"><span class="hidden-section">ContinuousBernoulli</span></a></li>
<li><a class="reference internal" href="#dirichlet"><span class="hidden-section">Dirichlet</span></a></li>
<li><a class="reference internal" href="#exponential"><span class="hidden-section">Exponential</span></a></li>
<li><a class="reference internal" href="#fishersnedecor"><span class="hidden-section">FisherSnedecor</span></a></li>
<li><a class="reference internal" href="#gamma"><span class="hidden-section">Gamma</span></a></li>
<li><a class="reference internal" href="#geometric"><span class="hidden-section">Geometric</span></a></li>
<li><a class="reference internal" href="#gumbel"><span class="hidden-section">Gumbel</span></a></li>
<li><a class="reference internal" href="#halfcauchy"><span class="hidden-section">HalfCauchy</span></a></li>
<li><a class="reference internal" href="#halfnormal"><span class="hidden-section">HalfNormal</span></a></li>
<li><a class="reference internal" href="#independent"><span class="hidden-section">Independent</span></a></li>
<li><a class="reference internal" href="#laplace"><span class="hidden-section">Laplace</span></a></li>
<li><a class="reference internal" href="#lognormal"><span class="hidden-section">LogNormal</span></a></li>
<li><a class="reference internal" href="#lowrankmultivariatenormal"><span class="hidden-section">LowRankMultivariateNormal</span></a></li>
<li><a class="reference internal" href="#mixturesamefamily"><span class="hidden-section">MixtureSameFamily</span></a></li>
<li><a class="reference internal" href="#multinomial"><span class="hidden-section">Multinomial</span></a></li>
<li><a class="reference internal" href="#multivariatenormal"><span class="hidden-section">MultivariateNormal</span></a></li>
<li><a class="reference internal" href="#negativebinomial"><span class="hidden-section">NegativeBinomial</span></a></li>
<li><a class="reference internal" href="#normal"><span class="hidden-section">Normal</span></a></li>
<li><a class="reference internal" href="#onehotcategorical"><span class="hidden-section">OneHotCategorical</span></a></li>
<li><a class="reference internal" href="#pareto"><span class="hidden-section">Pareto</span></a></li>
<li><a class="reference internal" href="#poisson"><span class="hidden-section">Poisson</span></a></li>
<li><a class="reference internal" href="#relaxedbernoulli"><span class="hidden-section">RelaxedBernoulli</span></a></li>
<li><a class="reference internal" href="#logitrelaxedbernoulli"><span class="hidden-section">LogitRelaxedBernoulli</span></a></li>
<li><a class="reference internal" href="#relaxedonehotcategorical"><span class="hidden-section">RelaxedOneHotCategorical</span></a></li>
<li><a class="reference internal" href="#studentt"><span class="hidden-section">StudentT</span></a></li>
<li><a class="reference internal" href="#transformeddistribution"><span class="hidden-section">TransformedDistribution</span></a></li>
<li><a class="reference internal" href="#uniform"><span class="hidden-section">Uniform</span></a></li>
<li><a class="reference internal" href="#vonmises"><span class="hidden-section">VonMises</span></a></li>
<li><a class="reference internal" href="#weibull"><span class="hidden-section">Weibull</span></a></li>
<li><a class="reference internal" href="#module-torch.distributions.kl"><cite>KL Divergence</cite></a></li>
<li><a class="reference internal" href="#module-torch.distributions.transforms"><cite>Transforms</cite></a></li>
<li><a class="reference internal" href="#module-torch.distributions.constraints"><cite>Constraints</cite></a></li>
<li><a class="reference internal" href="#module-torch.distributions.constraint_registry"><cite>Constraint Registry</cite></a></li>
</ul>
</li>
</ul>

            </div>
          </div>
        </div>
      </section>
    </div>

  


  

     
       <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
         <script src="_static/jquery.js"></script>
         <script src="_static/underscore.js"></script>
         <script src="_static/doctools.js"></script>
         <script src="_static/language_data.js"></script>
     

  

  <script type="text/javascript" src="_static/js/vendor/popper.min.js"></script>
  <script type="text/javascript" src="_static/js/vendor/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js"></script>
  <script type="text/javascript" src="_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>
 
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-90545585-1', 'auto');
  ga('send', 'pageview');

</script>

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-117752657-2"></script>

<script>
  window.dataLayer = window.dataLayer || [];

  function gtag(){dataLayer.push(arguments);}

  gtag('js', new Date());
  gtag('config', 'UA-117752657-2');
</script>

<img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&amp;guid=ON&amp;script=0"/>


  <!-- Begin Footer -->

  <div class="container-fluid docs-tutorials-resources" id="docs-tutorials-resources">
    <div class="container">
      <div class="row">
        <div class="col-md-4 text-center">
          <h2>Docs</h2>
          <p>Access comprehensive developer documentation for PyTorch</p>
          <a class="with-right-arrow" href="https://pytorch.org/docs/stable/index.html">View Docs</a>
        </div>

        <div class="col-md-4 text-center">
          <h2>Tutorials</h2>
          <p>Get in-depth tutorials for beginners and advanced developers</p>
          <a class="with-right-arrow" href="https://pytorch.org/tutorials">View Tutorials</a>
        </div>

        <div class="col-md-4 text-center">
          <h2>Resources</h2>
          <p>Find development resources and get your questions answered</p>
          <a class="with-right-arrow" href="https://pytorch.org/resources">View Resources</a>
        </div>
      </div>
    </div>
  </div>

  <footer class="site-footer">
    <div class="container footer-container">
      <div class="footer-logo-wrapper">
        <a href="https://pytorch.org/" class="footer-logo"></a>
      </div>

      <div class="footer-links-wrapper">
        <div class="footer-links-col">
          <ul>
            <li class="list-title"><a href="https://pytorch.org/">PyTorch</a></li>
            <li><a href="https://pytorch.org/get-started">Get Started</a></li>
            <li><a href="https://pytorch.org/features">Features</a></li>
            <li><a href="https://pytorch.org/ecosystem">Ecosystem</a></li>
            <li><a href="https://pytorch.org/blog/">Blog</a></li>
            <li><a href="https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md">Contributing</a></li>
          </ul>
        </div>

        <div class="footer-links-col">
          <ul>
            <li class="list-title"><a href="https://pytorch.org/resources">Resources</a></li>
            <li><a href="https://pytorch.org/tutorials">Tutorials</a></li>
            <li><a href="https://pytorch.org/docs/stable/index.html">Docs</a></li>
            <li><a href="https://discuss.pytorch.org" target="_blank">Discuss</a></li>
            <li><a href="https://github.com/pytorch/pytorch/issues" target="_blank">Github Issues</a></li>
            <li><a href="https://pytorch.org/assets/brand-guidelines/PyTorch-Brand-Guidelines.pdf" target="_blank">Brand Guidelines</a></li>
          </ul>
        </div>

        <div class="footer-links-col follow-us-col">
          <ul>
            <li class="list-title">Stay Connected</li>
            <li>
              <div id="mc_embed_signup">
                <form
                  action="https://twitter.us14.list-manage.com/subscribe/post?u=75419c71fe0a935e53dfa4a3f&id=91d0dccd39"
                  method="post"
                  id="mc-embedded-subscribe-form"
                  name="mc-embedded-subscribe-form"
                  class="email-subscribe-form validate"
                  target="_blank"
                  novalidate>
                  <div id="mc_embed_signup_scroll" class="email-subscribe-form-fields-wrapper">
                    <div class="mc-field-group">
                      <label for="mce-EMAIL" style="display:none;">Email Address</label>
                      <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="Email Address">
                    </div>

                    <div id="mce-responses" class="clear">
                      <div class="response" id="mce-error-response" style="display:none"></div>
                      <div class="response" id="mce-success-response" style="display:none"></div>
                    </div>    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->

                    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_75419c71fe0a935e53dfa4a3f_91d0dccd39" tabindex="-1" value=""></div>

                    <div class="clear">
                      <input type="submit" value="" name="subscribe" id="mc-embedded-subscribe" class="button email-subscribe-button">
                    </div>
                  </div>
                </form>
              </div>

            </li>
          </ul>

          <div class="footer-social-icons">
            <a href="https://www.facebook.com/pytorch" target="_blank" class="facebook"></a>
            <a href="https://twitter.com/pytorch" target="_blank" class="twitter"></a>
            <a href="https://www.youtube.com/pytorch" target="_blank" class="youtube"></a>
          </div>
        </div>
      </div>
    </div>
  </footer>

  <div class="cookie-banner-wrapper">
  <div class="container">
    <p class="gdpr-notice">To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: <a href="https://www.facebook.com/policies/cookies/">Cookies Policy</a>.</p>
    <img class="close-button" src="_static/images/pytorch-x.svg">
  </div>
</div>

  <!-- End Footer -->

  <!-- Begin Mobile Menu -->

  <div class="mobile-main-menu">
    <div class="container-fluid">
      <div class="container">
        <div class="mobile-main-menu-header-container">
          <a class="header-logo" href="https://pytorch.org/" aria-label="PyTorch"></a>
          <a class="main-menu-close-button" href="#" data-behavior="close-mobile-menu"></a>
        </div>
      </div>
    </div>

    <div class="mobile-main-menu-links-container">
      <div class="main-menu">
        <ul>
          <li>
            <a href="https://pytorch.org/get-started">Get Started</a>
          </li>

          <li>
            <a href="https://pytorch.org/features">Features</a>
          </li>

          <li>
            <a href="https://pytorch.org/ecosystem">Ecosystem</a>
          </li>

          <li>
            <a href="https://pytorch.org/mobile">Mobile</a>
          </li>

          <li>
            <a href="https://pytorch.org/hub">PyTorch Hub</a>
          </li>

          <li>
            <a href="https://pytorch.org/blog/">Blog</a>
          </li>

          <li>
            <a href="https://pytorch.org/tutorials">Tutorials</a>
          </li>

          <li class="active">
            <a href="https://pytorch.org/docs/stable/index.html">Docs</a>
          </li>

          <li>
            <a href="https://pytorch.org/resources">Resources</a>
          </li>

          <li>
            <a href="https://github.com/pytorch/pytorch">Github</a>
          </li>
        </ul>
      </div>
    </div>
  </div>

  <!-- End Mobile Menu -->

  <script type="text/javascript" src="_static/js/vendor/anchor.min.js"></script>

  <script type="text/javascript">
    $(document).ready(function() {
      mobileMenu.bind();
      mobileTOC.bind();
      pytorchAnchors.bind();
      sideMenus.bind();
      scrollToAnchor.bind();
      highlightNavigation.bind();
      mainMenuDropdown.bind();
      filterTags.bind();

      // Remove any empty p tags that Sphinx adds
      $("[data-tags='null']").remove();

      // Add class to links that have code blocks, since we cannot create links in code blocks
      $("article.pytorch-article a span.pre").each(function(e) {
        $(this).closest("a").addClass("has-code");
      });
    })
  </script>
</body>
</html>